1

If i visit https://pypi.python.org/pypi/pip, I can find the package to download - (pip-1.4.1.tar.gz), and this md5 hash with it (6afbb46aeb48abac658d4df742bff714 ).

I do not have an md5 tool so I wrote:

m = hashlib.md5()
f = 'pip-1.4.1.tar.GZ'
bin = open(f).read()
m.update(bin)
print m.hexdigest()

For both .GZ and .tar I dont get the listed md5 hash.

Edit: Solved it myself, but worth noting. This is one of those times that remembering the parameters for open helps - I was using

open(file)
  which implies
open(file, 'r')
  when i should have used
open(file, 'rb')  

Opening the binary file as binary made the read correct.

4

1 回答 1

0

Edit: Solved it myself, but worth noting. This is one of those times that remembering the parameters for open helps - I was using

open(file)
  which implies
open(file, 'r')
  when i should have used
open(file, 'rb')  Opening the binary file as binary made the read correct.
于 2013-11-07T12:03:51.193 回答