Created
November 7, 2018 05:38
-
-
Save raven4752/c13f8f0e7496c1b1aea97b796415f432 to your computer and use it in GitHub Desktop.
hash a file in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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