md5 from python different then md5 from command line

John Salerno johnjsal at NOSPAMgmail.com
Sun May 7 19:49:35 EDT 2006


Paul Rubin wrote:
> John Salerno <johnjsal at NOSPAMgmail.com> writes:
>> Any reason you can't just read the whole file at once and update m?
> 
> Yes, you could say
> 
>   print md5.new(file('foo.exe').read()).hexdigest()
> 
> 
> but that means reading the whole file into memory at once.  If the
> file is very large, that could thrash or fail.
> 
>> Also, doesn't the parameter for update have to be a string? If you're
>> reading the file in binary mode, would t still be a string?
> 
> Yes, t would still be a string.  You can have NUL bytes and so forth
> in Python strings:
> 
>     len('ab\0cd') ==>  5

Thanks! I didn't expect it to be so easy. :)



More information about the Python-list mailing list