Last active
October 20, 2015 07:42
-
-
Save pearofducks/4411558d2c8d0bbc84f2 to your computer and use it in GitHub Desktop.
python directory hasher - super quick and dirty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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