md5 for large files

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Tue Mar 4 18:57:53 EST 2003


On Tue, 04 Mar 2003 13:21:51 -0500, rumours say that Peter Hansen
<peter at engcorp.com> might have written:

>> Large is any file that I want to transfer around.  For example the gpg
>> library for windows that I just downloaded is a little over 1 mb and has a
>> defined md5 value that I'd like to compare.  
>
>Well, if you're really talking about such small "large" files, then don't
>worry about memory usage and just use Dave's solution without the reading-
>a-block-at-a-time thing:
>
>import md5
>m = md5.new()
>m.update(open('somefile','rb').read())
>print m.digest()

I believe m.hexdigest() will be more useful in this specific example for
comparison purposes.
-- 
TZOTZIOY, I speak England very best,
bofh at sil-tec.gr
(I'm a postmaster luring spammers; please spam me!
...and my users won't ever see your messages again...)




More information about the Python-list mailing list