Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86703

Md5 is different in Windows and Linux

Date 2015-03-02 12:04 +0545
Subject Md5 is different in Windows and Linux
From Sarvagya Pant <sarvagya.pant@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16.1425285828.13471.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hello, I am amazed that the  md5 of a file given by python in windows is
different than that of linux. Consider the following code:

import hashlib
def md5_for_file(f, block_size=2**20):
    md5 = hashlib.md5()
    while True:
        data = f.read(block_size)
        if not data:
            break
        md5.update(data)
    return md5.hexdigest()

f = open("somefile.txt")
print md5_for_file(f)

When I run the program I get the checksum value:
2f9cc8da53ee89762a34702f745d2956

But on this site http://onlinemd5.com/ and on linux it has value
E10D4E3847713472F51BC606852712F1.

Why is there difference in value of Checksum computed by python in windows
and other system.?

-- 
*sarvagya*

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Md5 is different in Windows and Linux Sarvagya Pant <sarvagya.pant@gmail.com> - 2015-03-02 12:04 +0545
  Re: Md5 is different in Windows and Linux Denis McMahon <denismfmcmahon@gmail.com> - 2015-03-02 10:24 +0000
  Re: Md5 is different in Windows and Linux sohcahtoa82@gmail.com - 2015-03-02 11:14 -0800
    Re: Md5 is different in Windows and Linux Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2015-03-03 00:45 +0100

csiph-web