Why HashValue function of TIdHMACSHA256+ (Indy/delphi) always return empty? For example, the code below does not work.
var
Hash: TIdHMACSHA256 ;
HashValue: TBytes;
begin
SetCurrentDir(ExtractFilePath(ParamStr(0)));
Hash := TIdHMACSHA256 .Create;
try
Hash.Key := TEncoding.ASCII.GetBytes('devaee2');
HashValue := Hash.HashValue(TFile.ReadAllBytes('menu.xml'));
// HashValue is an empty array, why?
Tag := Length(HashValue);
TFile.WriteAllBytes('menu.xml.hash', HashValue);
finally
FreeAndNil(Hash);
end;
end;
The problem is that you have not successfully loaded the OpenSSL libraries that are needed to implement the hash. Call IdSSLOpenSSL.LoadOpenSSLLibrary
. You'll also need to make sure that your program can find suitable OpenSSL DLLs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With