Skip to content

Instantly share code, notes, and snippets.

@pearofducks
Last active October 20, 2015 07:42
Show Gist options
  • Save pearofducks/4411558d2c8d0bbc84f2 to your computer and use it in GitHub Desktop.
Save pearofducks/4411558d2c8d0bbc84f2 to your computer and use it in GitHub Desktop.
python directory hasher - super quick and dirty
#!/usr/bin/env python
import os, hashlib
current_dir = os.getcwd()
hashes = []
for root,dirs,files in os.walk(current_dir):
for f in files:
current_file = os.path.join(root,f)
H = hashlib.md5()
try:
with open(current_file) as FIN:
H.update(FIN.read())
md5 = H.hexdigest()
hashes.append(md5)
print "{0}:\t{1}".format(current_file, md5)
except:
print "{0}: DOES NOT EXIST"
H = hashlib.md5()
H.update("".join(hashes))
print "HASH OF HASHES LOL:\t{0}".format(H.hexdigest())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment