Paul Rubin wrote: > John Salerno <[EMAIL PROTECTED]> writes: >> Just a quick md5-related follow-up question: I was experimenting with >> it and making md5 sums for strings, but how do you use the md5 module >> to create a sum for an actual file, such as an .exe file? > > m = md5.new() > f = file('foo.exe', 'b') # open in binary mode > while True: > t = f.read(1024) > if len(t) == 0: break # end of file > m.update(t) > print m.hexdigest()
Any reason you can't just read the whole file at once and update m? 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? Thanks. -- http://mail.python.org/mailman/listinfo/python-list