// StrBuf, StrBuf2, StrPad : ansistring
// bufin2 -> array[1..32768] of AnsiChar
// StrPad is assigned one of several, user selected,
// anti-collision protocols
repeat
BlockRead(InFile, Bufin2, SizeOf(Bufin2), NumRead);
BytsRem := BytsRem - NumRead;
NBlks := NBlks + 1;
StrBuf := '';
if NumRead > 0 then
for k := 1 to NumRead do //** extremely slow for large files
StrBuf := StrBuf+AnsiString(Bufin2[k]);
if NBlks = 1 then
StrBuf2 := AnsiString(StrPad+StrBuf)
else
StrBuf2 := AnsiString(StrBuf2+StrBuf);
MD5Long := MD5Hex(MD5Str(StrBuf2));
until (NumRead = 0) or (BytsRem = 0); // or (NBlks = 2);
Closefile(InFile);
// Completed hash is contained in MD5Long
// Most importantly, MD5Long agrees exactly with the
// binary "copied files" hash - see my #2.
|