i'm looking for a fast way for calculate a checksum of TStream (TMemoryStream). The purpose is store the hash and use it for detect if the checksum is changenged after some operation.
this is my code:
function GetChecksum(const Stream: TStream): String;
var
MD5: TIdHashMessageDigest5;
begin
MD5 := TIdHashMessageDigest5.Create;
try
Result := MD5.HashStreamAsHex(Stream);
finally
MD5.Free;
end;
end;
it works, but with a huge stream is a bit slow.
There is a fast way for calculate a stream checksum?
This code calculates MD5 - it is cryptographic hash, rather complex and slow.
For checksum you can try simpler algorithms like BobJenkinsHash
(S ystem.Hash.THashBobJenkins.GetHashValue ).
Also you can check performance of Spring4d and DCPCrypt implementations of MD5
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.