Skip to content

Instantly share code, notes, and snippets.

@imanabu
Last active August 29, 2015 14:15
Show Gist options
  • Save imanabu/f8fa0d56b8b031e68eb6 to your computer and use it in GitHub Desktop.
Save imanabu/f8fa0d56b8b031e68eb6 to your computer and use it in GitHub Desktop.
Python Gist
import hashlib
def hashfile(afile, hasher, blocksize=65536):
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
return hasher.digest()
[(fname, hashfile(open(fname, 'rb'), hashlib.sha256())) for fname in fnamelst]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment