def md5file(fobj): m = imd5.new() while True: d = fobj.read(8096) if not d: break m.update(d) fobj.seek(0) return m.hexdigest()