[Possible Bug-Python2.3.2] MD5 module?

Jeff Epler jepler at unpythonic.net
Wed Oct 13 20:31:45 EDT 2004


It works fine here.  When you use some other program to find the md5sum
of a file, does it have a trailing newline?  Your example code doesn't.

[jepler at sofa jepler]$ printf a | md5sum
0cc175b9c0f1b6a831c399e269772661  -
>>> import md5
>>> m = md5.new()
>>> m.update("a")
>>> print m.hexdigest()
0cc175b9c0f1b6a831c399e269772661

If the string you want to find the md5sum of has a newline, you'll get a
different hash value:
>>> m = md5.new(); m.update("a\n"); print m.hexdigest()
60b725f10c9c85c70d97880dfe8191b3
$ echo a | md5sum
60b725f10c9c85c70d97880dfe8191b3  -

If you are working with files on windows, be sure to open them with the
"b" flag.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041013/96789045/attachment.sig>


More information about the Python-list mailing list