md5 for large files
Peter Hansen
peter at engcorp.com
Tue Mar 4 13:21:51 EST 2003
Bob Ballard wrote:
> "Peter Hansen" <peter at engcorp.com> wrote:
> > Bob Ballard wrote:
> > >
> > > Can someone provide me with a snippet or pointer to usinging Python to
> > > verify the md5 value for a large file?
>
> > Define "large"...
>
> 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()
-Peter
More information about the Python-list
mailing list