Delphi Hash算法[4] SHA1

Delphi Hash算法[4] SHA1

引用单元:IdHashSHA

HashtoHex(const aHash:TidBytes):string;override;
HashBytesAsHex(const aHash:TidBytes):string;  //该方法将TidBytes类型返回string类;
HashStringAsHex(const AStr:String;ADestEncoding:TidTextEncoding=nil):string  //常规SHA1(utf-8)加密:40位SHA1大写

1、正常输出

uses IdHashSHA, IdGlobal;

function SHA1(Str: string): string;
begin
  with TIdHashSHA1.Create do
  try
    Result := LowerCase(HashBytesAsHex(TidBytes(Bytesof(Str))));  
  finally
    Free;
  end;
end;

2、UTF-8 格式输出

function sha1(Str: string): string;
begin
  with Tidhashsha1.Create do
  try
    Result := HashStringAsHex(Str,IndyTextEncoding_UTF8);
  finally
    free;
  end;
end;

  

 

 

创建时间:2021.04.29  更新时间:

上一篇:获取发布版SHA1和调试版SHA1


下一篇:如何利用insightface同时计算多个人脸相似度