Skip to content

Instantly share code, notes, and snippets.

@raven4752
Created November 7, 2018 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raven4752/c13f8f0e7496c1b1aea97b796415f432 to your computer and use it in GitHub Desktop.
Save raven4752/c13f8f0e7496c1b1aea97b796415f432 to your computer and use it in GitHub Desktop.
hash a file in python
import hashlib
def md5(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment