On Thu, Apr 19, 2012 at 5:46 PM, contro opinion <contropin...@gmail.com> wrote: >>>> import hashlib > >>>> f=open('c:\gpg4win-2.1.0.exe','rb') >>>> print hashlib.md5(f.read()).hexdigest() > ad6245f3238922bb7afdc4a6d3402a65 >>>> print hashlib.sha1(f.read()).hexdigest() > da39a3ee5e6b4b0d3255bfef95601890afd80709 > > i get it with md5,why the sha1 is wrong? > > the sha1 right is > > f619313cb42241d6837d20d24a814b81a1fe7f6d
After you read from the file, you can't read that content again without rewinding it. What you got there is this: >>> hashlib.sha1(b'').hexdigest() 'da39a3ee5e6b4b0d3255bfef95601890afd80709' Try again, but without getting the md5 first. ChrisA -- http://mail.python.org/mailman/listinfo/python-list