Change the MD5_Hash_Bytes procedure to
{ New MD5_Hash_Bytes procedure.
Andre v.d. Merwe
16-Sept-1997
Supports hashing of blocks larger than 4096 bytes
}
Procedure TMD5.MD5_Hash_Bytes;
var
Buffer : array[ 0..4159 ] of BYTE;
Index : LongInt;
Count64 : Comp;
NumRead : integer;
DoneBytes : boolean;
begin
Count64 := 0;
DoneBytes := false;
repeat
{Try to read 4096 bytes}
NumRead := 4096;
{If there is not 4098 bytes of data available read the remaining data}
if( NumRead > (InputLength - Round( Count64 )) ) then
NumRead := (InputLength - Round( Count64 ));
Count64 := Count64 + NumRead;
{Read data}
Move( PChar(pInputArray)[ Round( Count64 ) - NumRead ], PChar(@Buffer[ 0 ])^, NumRead );
{If <> 4096 then the last block of data has been read}
if( NumRead <> 4096 ) then
begin
Buffer[ NumRead ] := $80;
Inc( NumRead );
{Pad with zeros}
while( (NumRead mod 64) <> 56 ) do
begin
Buffer[ NumRead ] := 0;
Inc( NumRead );
end;
Count64 := Count64 * 8;
Move( Count64, Buffer[ NumRead ], 8 );
Inc( NumRead, 8 );
{Finished reading bytes}
DoneBytes := true;
end;
Index := 0;
repeat
Move( Buffer[ Index ], FActiveBlock, 64 );
MD5_Transform;
Inc( Index, 64 );
until( Index = NumRead );
until( DoneBytes );
end;