2012-02-16 20:26 md5 [permalink]
This is odd, it looks like there isn't an open source md5.pas unit. And by open source I mean under a permissive license or without copyright or licensing. So I set out to write my own and share it here. I based it on the original RFC, and even more the description than the reference implementation, because it uses a few of those C tricks I don't like. I hope it's performant enough, in case you're demanding performance of it. I've done some testing myself, but if you detect any kind of issue, please let me know.
MD5Hash for strings, sometimes used with passwords
MD5HashFromStream which takes any kind of stream (TFileStream, TMemoryStream...), and optionally a preset number of bytes to take from the stream (from the current position!).
Update: since MD5 and SHA1 are really similar, I've done the same for SHA1 and added sha1.pas and sha1Stream.pas.
Update 2: since I needed it for something else, I've added RIPEMD160 as well. And while I'm at it SHA256 as well
Update 3: added MurMurHash3...