Skip to content

Instantly share code, notes, and snippets.

import hashlib, zlib
HASH_BLOCKSIZE = 65536
def filebaidumd5(f, size=262144):
h1 = hashlib.md5()
h2 = 0
pos = 0
buf = f.read(min(HASH_BLOCKSIZE, size))
md5_at_size = None
while buf:
pos += len(buf)