472,984 Members | 2,123 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 software developers and data experts.

md5 wrongness?


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.
>>import md5
s = md5.new()
s.update('snagglefrob')
s.hexdigest()
'9eb2459fcdd9f9b8a9fef7348bcac933'

--
Ron Johnson, Jr.
Jefferson LA USA

%SYSTEM-F-FISH, my hovercraft is full of eels
Nov 24 '07 #1
4 1104
Ron Johnson wrote:
$ 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
s = md5.new()
s.update('snagglefrob')
s.hexdigest()
'9eb2459fcdd9f9b8a9fef7348bcac933'
echo inserts a newline, your Python snippet doesn't.

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

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
Granted that I must die, how shall I live?
-- Michael Novak
Nov 24 '07 #2
On Nov 24, 1:34 pm, Ron Johnson <ron.l.john...@cox.netwrote:
Why do Python's md5 and GNU md5sum produce differing results?
They don't differ. Try feeding them the same input:
>>import md5
md5.new('snagglefrob').hexdigest()
'9eb2459fcdd9f9b8a9fef7348bcac933'
>>md5.new('snagglefrob\n').hexdigest()
'f842244d79af85b457811091319d85ff'
>>>
>
$ 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
>s = md5.new()
s.update('snagglefrob')
s.hexdigest()

'9eb2459fcdd9f9b8a9fef7348bcac933'

--
Ron Johnson, Jr.
Jefferson LA USA

%SYSTEM-F-FISH, my hovercraft is full of eels
Nov 24 '07 #3
John Machin wrote:
On Nov 24, 1:34 pm, Ron Johnson <ron.l.john...@cox.netwrote:
>Why do Python's md5 and GNU md5sum produce differing results?

They don't differ. Try feeding them the same input:
>>>import md5
md5.new('snagglefrob').hexdigest()
'9eb2459fcdd9f9b8a9fef7348bcac933'
>>>md5.new('snagglefrob\n').hexdigest()
'f842244d79af85b457811091319d85ff'
>>>>
Or, alternatively:

$ echo -n snagglefrob | md5sum
9eb2459fcdd9f9b8a9fef7348bcac933 -

--
Ayaz Ahmed Khan
Nov 24 '07 #4
On 11/24/07 02:27, Ayaz Ahmed Khan wrote:
John Machin wrote:
>On Nov 24, 1:34 pm, Ron Johnson <ron.l.john...@cox.netwrote:
>>Why do Python's md5 and GNU md5sum produce differing results?
They don't differ. Try feeding them the same input:
>>>>import md5
md5.new('snagglefrob').hexdigest()
'9eb2459fcdd9f9b8a9fef7348bcac933'
>>>>md5.new('snagglefrob\n').hexdigest()
'f842244d79af85b457811091319d85ff'

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...

--
Ron Johnson, Jr.
Jefferson LA USA

%SYSTEM-F-FISH, my hovercraft is full of eels
Nov 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

111
by: JKop | last post by:
Okay here we go, I feel it's about time people conversed about the bullshit aspects of C++ (including the bullshit stuff brought forward from C). I'll begin with a few of my own grievances: 1)...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
35
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
12
by: Troy | last post by:
My ISP provides me with 2 servers: one for normal web hosting (non-PHP) and a CGI server (with PHP). I create my website using fusion 7 and upload this in its entirity to the web hosting server....
28
by: prunoki | last post by:
Hello, I am an SQL server newbie. Our company has a massive application written in PL/SQL. I need to port parts of it to SQL Server. - Which SQL server version should I choose, to have a...
143
by: suri | last post by:
Hello I downloaded glibc and tried looking for the code that implements the sine function i couldnt find the file. i went to the math directory and found math.h.. i guess that needs to be...
43
by: Dave Vandervies | last post by:
Seen in a chunk of code I was looking at recently (not mine!): -------- char* imgfilename; sprintf((char*)imgfilename, "mask%d.dib", params.profile); ReadImage((char*)imgfilename); --------...
9
by: QQ | last post by:
Hello I have a string like this "213200","0000","9999","204-033-105" but I need to seperate them to be s1 = 213200; s2 = 0000; s3 = 9999; s4 = 204-033-105; Is there any good way to do it?
67
by: Scott M. | last post by:
Can anyone give me any ideas on why VS.NET 2003 running on XP Pro. (P4's with 1GB RAM) would take over 3 minutes to simply create a new ASP.NET Web Application on http://localhost? It seems that...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.