Skip to content

Instantly share code, notes, and snippets.

@slow-is-fast
Created March 10, 2018 06:12
Show Gist options
  • Select an option

  • Save slow-is-fast/3f4c291098f0f651c21026766d136157 to your computer and use it in GitHub Desktop.

Select an option

Save slow-is-fast/3f4c291098f0f651c21026766d136157 to your computer and use it in GitHub Desktop.
python get file md5
#!/usr/bin/env 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