TidHashSHA512.isavailable is false on Windows 10

2019-05-25 01:08发布

I am using that function on Delphi XE2 to hash a string.

I have a bad result if the program is run on Windows 10 — the result is null because TidHashSHA512.isavailable is FALSE.

What do I have to do?

function HashSHA512String(Text: String): String;
var
  IdHashSHA512: TIdHashSHA512;
begin
  Result := '';
  if HashFunctionsOpenSSLLoaded then begin
    if TIdHashSHA512.IsAvailable then begin // <-- ADD THIS
      IdHashSHA512 := TIdHashSHA512.Create;
      try
        Result := IdHashSHA512.HashStringAsHex(Text);
      finally
        FreeAndNil(IdHashSHA512);
      end;
    end;
  end;
end;

标签: delphi indy
1条回答
兄弟一词,经得起流年.
2楼-- · 2019-05-25 01:38

Most of Indy's SHA hashes depend on your app hooking up an external hashing library to Indy. Only SHA-1 (amongst a few other non-SHA hashes) is currently implemented natively.

To enable SHA-512, the following callback function pointers in the IdFIPS unit must be assigned at runtime:

  • IsHashingIntfAvail
  • UpdateHashInst
  • FinalHashInst
  • IsSHA512HashIntfAvail
  • GetSHA512HashInst

You can use any hashing library you want, as long as the above function pointers are assigned to suitable functions.

Indy provides an implementation that uses hashing functions from OpenSSL. To use it, you can either:

  • add the IdSSLOpenSSLHeaders unit to your uses clause, and then call its Load() function at runtime.

  • add the IdSSLOpenSSL unit to your uses clause, and then call its LoadOpenSSLLibrary() function at runtime.

Either way, you will have to distribute the two OpenSSL DLLs with your app (libeay32.dll and ssleay32.dll, which you can download from Indy's Fulgan mirror). Be sure to use builds that have been compiled with SHA-512 enabled.

查看更多
登录 后发表回答