DELPHI Hmac-SHA256算法问题
按下面的代码算法得到的结果后在线验证,只能得到下图的1,2(https://1024tools.com/hmac)
uses
IdGlobal, IdHashSHA, IdHMAC, IdHMACSHA1, IdSSLOpenSSL;
function CalculateHMACSHA256_64(const value, salt: String): String;
var
hmac: TIdHMACSHA256;
hash: TIdBytes;
begin
LoadOpenSSLLibrary;
if not TIdHashSHA256.IsAvailable then
raise Exception.Create('SHA256 hashing is not available!');
hmac := TIdHMACSHA256.Create;
try
hmac.Key := IndyTextEncoding_UTF8.GetBytes(salt);
hash := hmac.HashValue(IndyTextEncoding_UTF8.GetBytes(value));
Result := ToHex(hash);
Result :=EncodeString(Result );
finally
hmac.Free;
end;
end;
注意:软件目录要放 libeay32.dll ssleay32.dll
来源:https://ask.csdn.net/questions/7447057
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.044996976852417 seconds