The buffer in the above function is too small.
The algorithm uses more then 64 extra bytes than the source-data:
procedure TCrMD5.MD5_Hash_Bytes;
const
cExtBuffer = 64+8;
...
begin
if FSourceLength + cExtBuffer < SizeOf(SttBuf) then
begin
...
end
else
begin
SetLength(DynBuf, FSourceLength + cExtBuffer);
...
end;
...
end;
BTW.
Isn't it better always use a dynamic array and remove the code which uses SttBuf: array[0..1024] of Byte?
Comments