解决方案 »
- 求对 结构体 固定压缩率 的算法
- 判断焦点的问题:点击时,如何判断焦点在哪个控件上?
- 把SQL SERVER 2000中一个数据库中所有表的数据拷贝到Interbase数据库中
- delphi5或delphi7连接oracle9i,如果表中有blob字段则出错,怎么办?
- 高难度 用TABLE连接access时出现用户名 密码是怎么回事?如何用DBGRID控件显四ACCESS表
- 如何判断某一目录下是否存在某一文件???在线等待!!!
- query.edit出现了cannot modify a read_only dataset的错误是为什么呢》》
- 怎么样退出FORM?
- delphi combobox嵌入dbgrid
- 那里有 installshield for delphi5.0 下的地方?
- 请问关联表查询问题如何处理??
- [Help]各路高手请帮忙! 关于DLL, Hook,回调函数[Help]
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}
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.
小弟愚笨,想弱弱的问下,具体怎么用啊?
例如
明文是:'abcdefg'
密匙是:’123456‘参数该往那里填?结果又从那里得到?
复制出以下文件到你自己的工程
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.
运行结果
密匙是:’123456‘得出这个结果,不正确吧!?
明文是:'abcdefg'
密匙是:’123456‘又换了家网站,hamc-sha384计算结果还是
407ed......1c66也奇葩了!就是384不一样。
其他的,都核对无误!!到底是哪个对!?