/ / TIdHMACSHA256.TIdHMACSHA384.TIdHMACSHA512 no funciona en Delphi - delphi, indy

TIdHMACSHA256.TIdHMACSHA384.TIdHMACSHA512 no funcionan en Delphi - delphi, indy

¿Por qué la función HashValue de TIdHMACSHA256 + (Indy / delphi) siempre vuelve vacía? Por ejemplo, el siguiente código no funciona.

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;

Respuestas

2 para la respuesta № 1

Mirando rápidamente las fuentes de Indy 10, no tienen códigos hash SHA256-512r codificados, y usan algún tipo de hashes del sistema (??). Verifique TIdHashSHA256.IsAvailable; lo más probable es que devuelva falso.


6 para la respuesta № 2

El problema es que no ha cargado correctamente las bibliotecas OpenSSL que se necesitan para implementar el hash. Llamada IdSSLOpenSSL.LoadOpenSSLLibrary. También deberá asegurarse de que su programa pueda encontrar archivos DLL de OpenSSL adecuados.


0 para la respuesta № 3

Busque el componente TDCP (intente https://bitbucket.org/wpostma/dcpcrypt2010) La fuente está completa. Funciona bien en Rad Studio 2007 ... XE5 Originario de Delphi, tienes SHA1 pero no SHA2 y otros (creo que por ley, o no sé ...)