Skip to content

Instantly share code, notes, and snippets.

@MerleLiuKun
Last active March 6, 2018 11:47
Show Gist options
  • Save MerleLiuKun/82bf3c2a1addebef7b8f49448504d92b to your computer and use it in GitHub Desktop.
Save MerleLiuKun/82bf3c2a1addebef7b8f49448504d92b to your computer and use it in GitHub Desktop.
python encrypt large file with md5
def md5_for_file(path):
path = path.encode('utf-8')
md = hashlib.md5()
block_size = 128 * md.block_size
with open(path, 'rb') as f:
for chunk in iter(lambda: f.read(block_size), b''):
md.update(chunk)
return md.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment