/* vi: set tabstop=4 nocindent noautoindent: */ /** 暗号用ライブラリ cipher.c ヘッダ #include "cipher.h" */ #include "cipher.h" /** Buffer xlcrypt(Buffer str, Buffer salt) 機能: crypt関数(DES)による passwdの多重(2回)ハッシュ値化. saltの長さに応じて,パスワードを多重にハッシュ値化する. saltの2Byte毎に一回ハッシュ値化を行う. 引数: passwd ハッシュ値化するパスワード. salt saltキー.(文字列) 戻り値: ハッシュ値されたパスワードストリング.saltキーは返さない.通常 11Byte. */ Buffer xlcrypt(Buffer str, Buffer salt) { int i, len, lsalt; char* passwd; char pass[LPASS+1]; Buffer ret; memset(pass, 0, LPASS+1); len = Min((int)strlen((const char*)str.buf), LPASS); memcpy(pass, str.buf, len); lsalt = ((int)strlen((const char*)salt.buf)/2)*2; if (lsalt>=2) { passwd = (char*)crypt((const char*)pass, (const char*)salt.buf); if (strncmp((const char*)salt.buf, "$1$", 3)) { // DES for (i=2; i