Page 1 of 1

OpenSSL and MD5Fingerprint

Posted: Sun Aug 07, 2011 9:04 pm
by safra
Head scratcher here which will require some Linux knowledge. I'm using Purebasic in Windows XP, but need someone to explain what is going on:

(Ubuntu):

Code: Select all

echo -n "william" | openssl dgst -md5
Result: fd820a2b4461bddd116c1518bc4b0f77

(Purebasic XP):

Code: Select all

me$="william"
Debug MD5Fingerprint(@me$, Len(me$))
Result: fd820a2b4461bddd116c1518bc4b0f77

Both are the same. However, in Linux, if you add the binary option you get something almost the same. Check the first four characters, they are swapped around, the hash is almost the same all the way through, but not quite. What exactly is the -binary option doing and how can I replicate it in Purebasic please? (Is it called 'raw md5'?)

(Ubuntu):

Code: Select all

 echo -n "william" | openssl dgst -md5 -binary | hexdump
Result: [0000000] 82fd 2b0a 6144 ddbd 6c11 1815 4bbc 770f

Re: OpenSSL and MD5Fingerprint

Posted: Sun Aug 07, 2011 9:43 pm
by moogle
looks like the hash is split into 8 sections of 4 characters and reversed in groups of 2. That's all.

Re: OpenSSL and MD5Fingerprint

Posted: Sun Aug 07, 2011 10:31 pm
by safra
Thanks, I was thinking other parts of it changed aside from the reversal thing - seems I'm wrong on that count. Would still like to know why the reverse thing happens though, if anyone has an idea.

Re: OpenSSL and MD5Fingerprint

Posted: Sun Aug 07, 2011 10:50 pm
by moogle
safra wrote:Thanks, I was thinking other parts of it changed aside from the reversal thing - seems I'm wrong on that count. Would still like to know why the reverse thing happens though, if anyone has an idea.
could be to do with the way the system reads the bytes (endian stuff) maybe?
Someone who uses Linux a bit more might be able to explain.