TidHashSHA512.isavailable is false on Windows 10

风格不统一 提交于 2019-12-10 10:42:40

问题


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;

回答1:


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.



来源:https://stackoverflow.com/questions/47379509/tidhashsha512-isavailable-is-false-on-windows-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!