想知道在sha1算法中的长度为64的常量字符串是做什么用的?另外在初始化hash的时候对其中的一个结果进行操作,结构如下:
PSHA256Ctx = ^TSHA256Ctx;
TSHA256Ctx = record
state: array[0..7] of LongWord;
length, curlen: LongWord;
buf: array[0..63] of Byte;
end;
谁能帮我讲讲这个结构是用来干什么的?
我实在是看不明白,请各位大侠赐教
PSHA256Ctx = ^TSHA256Ctx;
TSHA256Ctx = record
state: array[0..7] of LongWord;
length, curlen: LongWord;
buf: array[0..63] of Byte;
end;
谁能帮我讲讲这个结构是用来干什么的?
我实在是看不明白,请各位大侠赐教
PSHA256Ctx 为指向TSHA256Ctx的指针
我的定义为:
type
TSHA1Context= record
Hash: array[0..4] of DWord;
Hi, Lo: integer;
Buffer: array[0..63] of byte;
Index: integer;
end;
然后对sh1初始化时:
procedure SHA1Init(var Context: TSHA1Context);
begin
Context.Hi:= 0; Context.Lo:= 0;
Context.Index:= 0;
FillChar(Context.Buffer,Sizeof(Context.Buffer),0);
Context.Hash[0]:= $67452301;
Context.Hash[1]:= $EFCDAB89;
Context.Hash[2]:= $98BADCFE;
Context.Hash[3]:= $10325476;
Context.Hash[4]:= $C3D2E1F0;
end;
sh1中的buffer是存放sh1运算的初始数据及中间结果的(共64字节)
充分利用RAD的优势~