The MD5 Message-Digest algorithm is a cryptographic hash function. MD5 is commonly used to check the integrity of files. An MD5 hash value is a 32 digit hexadecimal number.
MD5 for filesUsing Delphi, you can easily create a function to calculate the MD5 hash for a given file. All you need is included in two units (part of Indy): IdHashMessageDigest and idHash.
You can use MD5 file hashing to enusure that after a (some kind of file) transfer the file has arrived intact.
uses IdHashMessageDigest, idHash; //returns MD5 has for a file function MD5(const fileName : string) : string; var idmd5 : TIdHashMessageDigest5; fs : TFileStream; hash : T4x4LongWordRecord; begin idmd5 := TIdHashMessageDigest5.Create; fs := TFileStream.Create(fileName, fmOpenRead OR fmShareDenyWrite) ; try result := idmd5.AsHex(idmd5.HashValue(fs)) ; finally fs.Free; idmd5.Free; end; end;