MD5 hash differences between Python and other file hashers

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-05-25T17:20:54Z Indexed on 2010/05/25 18:41 UTC
Read the original article Hit count: 219

Filed under:
|
|

I have been doing a bit of programming in Python (still a n00b at it) and came across something odd. I made a small program to find the MD5 hash of a filename passed to it on the command line. I used a function I found here on SO. When I ran it against a file, I got a hash "58a...113". But when I ran Microsoft's FCIV or the md5sum.py in \Python26\Tools\Scripts\, I get a different hash, "591...ae6". The actual hashing part of the md5sum.py in Scripts is

m = md5.new()
while 1:
    data = fp.read(bufsize)
    if not data:
        break
    m.update(data)
out.write('%s %s\n' % (m.hexdigest(), filename))

This looks functionally identical to the code in the function given in the other answer... What am I missing? (This is my first time posting to stackoverflow, please let me know if I am doing it wrong.)

© Stack Overflow or respective owner

Related posts about python

Related posts about hash