MD5 file hashing - matching Delphi output with PHP function md5_file

I am currently using this code to hash md5 in Delphi 7:

function MD5(const fileName : string) : string; var idmd5 : TIdHashMessageDigest5; fs : TFileStream; 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; 

and I'm trying to get the output just like a PHP function

 md5_file() 

I looked around and the usual problems look like an encoding rather than padding with zeros, but I don’t know how to do this using TIdHashMessageDigest5, or they are already executed in this function.

If anyone has any features that they use for this, it will be very useful!

Or perhaps a way to change the php function to match Indy one

+2
source share
2 answers

Compare the results with:

If all but one agree on the amount, then you know where to dig.

+6
source

Well, you did not specify the Delphi version number, but if you are on D2007 or later, you can check out this article.

+3
source

All Articles