OpenSSL and MD5Fingerprint

Just starting out? Need help? Post your questions and find answers here.
safra
New User
New User
Posts: 7
Joined: Thu May 07, 2009 8:36 pm

OpenSSL and MD5Fingerprint

Post 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
moogle
Enthusiast
Enthusiast
Posts: 372
Joined: Tue Feb 14, 2006 9:27 pm
Location: London, UK

Re: OpenSSL and MD5Fingerprint

Post by moogle »

looks like the hash is split into 8 sections of 4 characters and reversed in groups of 2. That's all.
Image
safra
New User
New User
Posts: 7
Joined: Thu May 07, 2009 8:36 pm

Re: OpenSSL and MD5Fingerprint

Post 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.
moogle
Enthusiast
Enthusiast
Posts: 372
Joined: Tue Feb 14, 2006 9:27 pm
Location: London, UK

Re: OpenSSL and MD5Fingerprint

Post 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.
Image
Post Reply