md5 wrongness?

R

Ron Johnson

Why do Python's md5 and GNU md5sum produce differing results?

$ md5sum --version
md5sum (GNU coreutils) 5.97

$ echo snagglefrob | md5sum
f842244d79af85b457811091319d85ff -
$ echo 'snagglefrob' | md5sum
f842244d79af85b457811091319d85ff -
$ echo "snagglefrob" | md5sum
f842244d79af85b457811091319d85ff -


$ python
Python 2.4.4 (#2, Aug 16 2007, 02:03:40)
[GCC 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.'9eb2459fcdd9f9b8a9fef7348bcac933'
 
E

Erik Max Francis

Ron said:
$ echo "snagglefrob" | md5sum
f842244d79af85b457811091319d85ff -

$ python
Python 2.4.4 (#2, Aug 16 2007, 02:03:40)
[GCC 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.'9eb2459fcdd9f9b8a9fef7348bcac933'

echo inserts a newline, your Python snippet doesn't.

% echo -n "snagglefrob" | md5sum
9eb2459fcdd9f9b8a9fef7348bcac933 -
 
J

John Machin

Why do Python's md5 and GNU md5sum produce differing results?

They don't differ. Try feeding them the same input:
$ md5sum --version
md5sum (GNU coreutils) 5.97

$ echo snagglefrob | md5sum
f842244d79af85b457811091319d85ff -
$ echo 'snagglefrob' | md5sum
f842244d79af85b457811091319d85ff -
$ echo "snagglefrob" | md5sum
f842244d79af85b457811091319d85ff -

$ python
Python 2.4.4 (#2, Aug 16 2007, 02:03:40)
[GCC 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>> import md5
'9eb2459fcdd9f9b8a9fef7348bcac933'

--
Ron Johnson, Jr.
Jefferson LA USA

%SYSTEM-F-FISH, my hovercraft is full of eels
 
A

Ayaz Ahmed Khan

John said:
They don't differ. Try feeding them the same input:

Or, alternatively:

$ echo -n snagglefrob | md5sum
9eb2459fcdd9f9b8a9fef7348bcac933 -
 
R

Ron Johnson

Or, alternatively:

$ echo -n snagglefrob | md5sum
9eb2459fcdd9f9b8a9fef7348bcac933 -

Thanks to all. I knew there had to be operator error, but I
couldn't figure out where...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top