Md5 is different in Windows and Linux

sohcahtoa82 at gmail.com sohcahtoa82 at gmail.com
Mon Mar 2 14:14:17 EST 2015


On Monday, March 2, 2015 at 12:43:59 AM UTC-8, Sarvagya Pant wrote:
> 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

I don't know which is worse, the fact that you're composing your message in HTML, or the fact that you're using Comic Sans as your font.



More information about the Python-list mailing list