我具有此功能,可生成BobJenkinsHash的TStream
的校验和:
function GetStreamHashBobJenkins(Stream: TStream): String;
var
Hash: THashBobJenkins;
Readed: Integer;
Buffer: PByte;
BufLen: Integer;
begin
Hash := THashBobJenkins.Create;
BufLen := 16 * 1024;
Buffer := AllocMem(BufLen);
try
Stream.Seek(0, 0);
while Stream.Position < Stream.Size do begin
Readed := Stream.Read(Buffer^, BufLen);
if Readed > 0 then begin
Hash.update(Buffer^, Readed);
end;
end;
Stream.Seek(0, 0);
finally
FreeMem(Buffer)
end;
Result := Hash.HashAsString;
end;
我从System.Generics.Defaults.BobJenkinsHash的文档维基中读到:
BobJenkinsHash用于生成内存块的哈希码。
维基似乎在谈论通用的“内存块”,是否可能生成通用TObject
的校验和?