md5 check

MRAB python at mrabarnett.plus.com
Wed Apr 18 22:16:03 EDT 2012


On 19/04/2012 02:43, Jerry Hill wrote:
> On Wed, Apr 18, 2012 at 9:31 PM, contro opinion<contropinion at gmail.com>  wrote:
>>  i have download  file (gpg4win-2.1.0.exe  from
>>  http://www.gpg4win.org/download.html)
>>  when i run :
>>
>>  Type "help", "copyright", "credits" or "license" for
>>>>>  import md5
>>>>>  f=open('c:\gpg4win-2.1.0.exe','r')
>>>>>  print md5.new(f.read()).hexdigest()
>>  'd41d8cd98f00b204e9800998ecf8427e'
>>
>>  it is not  =  f619313cb42241d6837d20d24a814b81a1fe7f6d gpg4win-2.1.0.exe
>>  please see   :gpg4win-2.1.0.exe  from  http://www.gpg4win.org/download.html
>>
>>  why ?
>
> Probably because you opened the file in text mode, instead of binary
> mode.  Try opening the file this way:
>
>   f=open('c:\gpg4win-2.1.0.exe','rb')
>
When working with paths in Windows it's a good idea to use raw strings
or forward slashes:

     f = open(r'c:\gpg4win-2.1.0.exe', 'rb')

or:

     f = open('c:/gpg4win-2.1.0.exe', 'rb')



More information about the Python-list mailing list