Skip to content

Instantly share code, notes, and snippets.

@dniku
Last active June 16, 2016 17:57
Show Gist options
  • Save dniku/24e734a5ece3289ab0e2326808b0da05 to your computer and use it in GitHub Desktop.
Save dniku/24e734a5ece3289ab0e2326808b0da05 to your computer and use it in GitHub Desktop.
import os, hashlib
data = []
for fname in sorted(os.listdir('.')):
if os.path.isfile(fname):
with open(fname, 'rb') as f:
contents = f.read()
data.append((fname, hashlib.sha1(contents).hexdigest()))
with open('hashes.txt', 'w') as f:
for fname, sha1 in data:
f.write('%s %s\n' % (sha1, fname))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment