千
千中元
Unregistered / Unconfirmed
GUEST, unregistred user!
用了个加密的第三方控件,Tcryptlib(可以到深度历险里下载)。在示例程序中,
设置密码的Edit:EditPwd
还有一个Edit:EditHash,
在EditHash旁边有一个label,说明EditHash:PassWord Hash(32bytes)
这个Hash在这里怎么解释好呢?
比如设置密码的时候,用下面的代码:
CryptLib1.Password:=Trim(EditPwd.Text);
EditHash.Text:=CryptLib1.PasswdHash;
EditChkHash.Text:=EditHash.Text;------
EditChkPwd.Text:=EditPwd.Text;
------后两行好像是检验密码的
其中PasswdHash的代码是:
function TCryptLib.PasswdHash : String;
begin
{ generate string hash value using FPassword and Salt (random value)
you can write this string to ini file or registry in order to
check your password in future }
InitKey;
EncryptCore(CrcArr, 16);
{ adding an random value depends of the system time to CRC of a random array }
Result:=IntToHex(CRC(CrcArr^) xor Salt,8)+IntToHex(Salt,8);
Dispose(CrcArr);
{ initilazed in InitKey }
Result:=EncryptStr(Result);
{ encrypting a result string }
end;
设置密码的Edit:EditPwd
还有一个Edit:EditHash,
在EditHash旁边有一个label,说明EditHash:PassWord Hash(32bytes)
这个Hash在这里怎么解释好呢?
比如设置密码的时候,用下面的代码:
CryptLib1.Password:=Trim(EditPwd.Text);
EditHash.Text:=CryptLib1.PasswdHash;
EditChkHash.Text:=EditHash.Text;------
EditChkPwd.Text:=EditPwd.Text;
------后两行好像是检验密码的
其中PasswdHash的代码是:
function TCryptLib.PasswdHash : String;
begin
{ generate string hash value using FPassword and Salt (random value)
you can write this string to ini file or registry in order to
check your password in future }
InitKey;
EncryptCore(CrcArr, 16);
{ adding an random value depends of the system time to CRC of a random array }
Result:=IntToHex(CRC(CrcArr^) xor Salt,8)+IntToHex(Salt,8);
Dispose(CrcArr);
{ initilazed in InitKey }
Result:=EncryptStr(Result);
{ encrypting a result string }
end;