Does hashlib support a file mode?
phlip2005 at gmail.com
Wed Jul 6 18:49:10 CEST 2011
> - Open the file in binary mode.
I had tried open(path, 'rb') and it didn't change the "wrong" number.
And I added --binary to my evil md5sum version, and it didn't change
the "right" number!
Gods bless those legacy hacks that will never die, huh? But I'm using
Ubuntu (inside VMWare, on Win7, on a Core i7, because I rule), so that
might explain why "binary mode" is a no-op.
> - Do the usual dance for default arguments:
> def file_to_hash(path, m=None):
> if m is None:
> m = hashlib.md5()
Not sure why if that's what the defaulter does? I did indeed get an
MD5-style string of what casually appeared to be the right length, so
that implies the defaulter is not to blame...
More information about the Python-list