Skip to content

Instantly share code, notes, and snippets.

@slow-is-fast
Created March 18, 2020 02:38
Show Gist options
  • Save slow-is-fast/341cb9badff177981072bf5ccbb9c3c9 to your computer and use it in GitHub Desktop.
Save slow-is-fast/341cb9badff177981072bf5ccbb9c3c9 to your computer and use it in GitHub Desktop.
file_md5 in python
import hashlib

def file_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