zoukankan      html  css  js  c++  java
  • system.hash.pas

    system.hash.pas

    delphi xe8开始提供system.hash.pas。

    xe10.4.1版本,提供有几个记录:

    THash = record

    THashBobJenkins = record

    THashMD5 = record

    THashSHA1 = record

    THashSHA2 = record

    uses  System.Hash;
    
    function md5_hmac(const val, key: string): string;
    begin
      var md5: THashMD5 := THashMD5.Create;
      Result := md5.GetHMAC(val, key);
    end;
    
    function md5_utf8(const val: string): string;
    begin
      var md5: THashMD5 := THashMD5.Create;
      md5.Update(TEncoding.UTF8.GetBytes(val));
      Result := md5.HashAsString;
    end;
    
    function sha1_utf8(const val: string): string;
    begin
      var sha1: THashSHA1 := THashSHA1.Create;
      sha1.Update(TEncoding.UTF8.GetBytes(val));
      Result := sha1.HashAsString;
    end;
    
    function sha2_utf8(const val: string): string;
    begin
      var sha2: THashSHA2 := THashSHA2.Create;
      sha2.Update(TEncoding.UTF8.GetBytes(val));
      Result := sha2.HashAsString;
    end;
    
    procedure TForm2.Button1Click(Sender: TObject);
    begin
      Memo1.Lines.Add(md5_utf8('咏南中间件'));         //ce33960c8f97c85161a8b28b7000b3c6
      Memo1.Lines.Add(sha1_utf8('咏南中间件'));        //2566ca7678fcdb309846eabef3911dc6e5f8814d
      Memo1.Lines.Add(sha2_utf8('咏南中间件'));        //f3bbbfaf81071d67f02fd519553789c671c7e0514045885e5bd8faa80d66792f
      Memo1.Lines.Add(md5_hmac('咏南中间件', '钥匙')); //0796b66fa3180024cb5e49cba66dbf58
    end;
    

      

  • 相关阅读:
    Linux内核TSS的使用
    DPL, CPL及RPL之间的关系
    Linux内存管理(深入理解Linux内核)
    Windows下安装PIL进行图像处理
    内存Zone中的pageset成员分析
    导出符号的意义
    GDI及Windows的消息机制
    kmalloc vs vmalloc
    Linux Kernel Development有关内存管理
    STL sort
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/14276734.html
Copyright © 2011-2022 走看看