[Possible Bug-Python2.3.2] MD5 module?

Jeff Epler jepler at unpythonic.net
Thu Oct 14 02:31:45 CEST 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.pgp>


More information about the Python-list mailing list