解决方案 »

  1.   

    http://www.wolfgang-ehrhardt.de/crc_hash_2014-08-25.ziphmacsha2.pas
    procedure hmac_SHA256_init(var ctx: THMAC_Context; key: pointer; klen: word);
      {-initialize HMAC context with key}
      {$ifdef DLL} stdcall; {$endif}procedure hmac_SHA256_inits(var ctx: THMAC_Context; skey: Str255);
      {-initialize HMAC context with skey}
      {$ifdef DLL} stdcall; {$endif}procedure hmac_SHA256_update(var ctx: THMAC_Context; data: pointer; dlen: word);
      {-HMAC data input, may be called more than once}
      {$ifdef DLL} stdcall; {$endif}procedure hmac_SHA256_updateXL(var ctx: THMAC_Context; data: pointer; dlen: longint);
      {-HMAC data input, may be called more than once}
      {$ifdef DLL} stdcall; {$endif}procedure hmac_SHA256_final(var ctx: THMAC_Context; var mac: TSHA256Digest);
      {-end data input, calculate HMAC digest}
      {$ifdef DLL} stdcall; {$endif}
      

  2.   

    hmac sha256有现成的,把这个改sha384就可以,文件很简单,看下就能改。
      

  3.   

    下面是改好的384
    unit HMACSHA3;interface{$i STD.INC}uses
      BTypes,Hash,HMAC,SHA384;
    procedure hmac_SHA384_init(var ctx: THMAC_Context; key: pointer; klen: word);
      {-initialize HMAC context with key}
      {$ifdef DLL} stdcall; {$endif}procedure hmac_SHA384_inits(var ctx: THMAC_Context; skey: Str255);
      {-initialize HMAC context with skey}
      {$ifdef DLL} stdcall; {$endif}procedure hmac_SHA384_update(var ctx: THMAC_Context; data: pointer; dlen: word);
      {-HMAC data input, may be called more than once}
      {$ifdef DLL} stdcall; {$endif}procedure hmac_SHA384_updateXL(var ctx: THMAC_Context; data: pointer; dlen: longint);
      {-HMAC data input, may be called more than once}
      {$ifdef DLL} stdcall; {$endif}procedure hmac_SHA384_final(var ctx: THMAC_Context; var mac: TSHA384Digest);
      {-end data input, calculate HMAC digest}
      {$ifdef DLL} stdcall; {$endif}implementation
    {---------------------------------------------------------------------------}
    procedure hmac_SHA384_init(var ctx: THMAC_Context; key: pointer; klen: word);
      {-initialize HMAC context with key}
    var
      phash: PHashDesc;
    begin
      phash := FindHash_by_ID(_SHA384);
      hmac_init(ctx, phash, key, klen);
    end;
    {---------------------------------------------------------------------------}
    procedure hmac_SHA384_inits(var ctx: THMAC_Context; skey: Str255);
      {-initialize HMAC context with skey}
    begin
      hmac_SHA384_init(ctx, @skey[1], length(skey));
    end;
    {---------------------------------------------------------------------------}
    procedure hmac_SHA384_update(var ctx: THMAC_Context; data: pointer; dlen: word);
      {-HMAC data input, may be called more than once}
    begin
      hmac_updateXL(ctx, data, dlen);
    end;
    {---------------------------------------------------------------------------}
    procedure hmac_SHA384_updateXL(var ctx: THMAC_Context; data: pointer; dlen: longint);
      {-HMAC data input, may be called more than once}
    begin
      hmac_updateXL(ctx, data, dlen);
    end;
    {---------------------------------------------------------------------------}
    procedure hmac_SHA384_final(var ctx: THMAC_Context; var mac: TSHA384Digest);
      {-end data input, calculate HMAC digest}
    var
      d: THashDigest;
    begin
      hmac_final(ctx, d);
      move(d, mac, sizeof(mac));
    end;end.
      

  4.   

    要生成Dll,然后调用动态联结库?
    小弟愚笨,想弱弱的问下,具体怎么用啊?
    例如 
    明文是:'abcdefg'
    密匙是:’123456‘参数该往那里填?结果又从那里得到?
      

  5.   

    解压的项目,一编译就报错  error('compile with $define DLL');错在这句上。具体怎么用啊?
      

  6.   


    复制出以下文件到你自己的工程
    btypes.pas
    hash.pas
    hmac.pas
    hmacsha3.pas(楼上已经给出)
    sha256.pas
    sha384.pas
    sha512.pas
    std.inc调用范例
    program hmac_sha384_example;{$APPTYPE CONSOLE}uses
      SysUtils, hmac, hash, hmacsha3;
    const
      data = 'abcdefg';
      key = '123456';var
      HMacContent: THMAC_Context;
      mac: TSHA384Digest;
      i: Integer;begin
      hmac_SHA384_init(HMacContent, PChar(key), Length(key));
      hmac_SHA384_updateXL(HMacContent, PChar(data), Length(data));
      hmac_SHA384_final(HMacContent, mac);
      for i := 0 to Length(mac) do
        Write(Format('%.2x',[mac[i]]));
      Readln;
    end.
    运行结果
      

  7.   

    明文是:'abcdefg'
    密匙是:’123456‘得出这个结果,不正确吧!?
      

  8.   

    你找的那网站计算有问题罢了,我这边用第三方算hash的工具验算是正确的。
      

  9.   


    明文是:'abcdefg'
    密匙是:’123456‘又换了家网站,hamc-sha384计算结果还是
    407ed......1c66也奇葩了!就是384不一样。
    其他的,都核对无误!!到底是哪个对!?
      

  10.   

    你找的这俩个网站,都用的CryptoJS,同个库,个人认为软件正确的可能性高。
      

  11.   

    golang也是这个结果,所以,确定cryptojs是错误的。http://ideone.com/NzEqQu