md5 from python different then md5 from command line

Paul Rubin http
Sun May 7 19:13:25 EDT 2006


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



More information about the Python-list mailing list