As an exercise, I'm attempting to implement MD5 in PHP. I know PHP has a built-in function for this but I would like to read, run and study a working source. I found this script which works great when appropriate sections are uncommented (to enable message padding) and arrays are formatted accordingly (for compatibility for my version of PHP.) However the hash produced - despite being of correct length - is not MD5. For example, the MD5 hash for a zero length string should be:
d41d8cd98f00b204e9800998ecf8427e
but the hash returned by the script for the same is:
85bd946a585af9fd3fb9eda68707c1d8
I've tried other strings but there is no correlation. I've been studying MD5 so have a reasonable knowledge of how it works. I've been interrogating the script but it seems legitimate. I guess I'm giving a shout out to another up for the challenge of discovering why this script isn't returning MD5.