Created
May 4, 2015 01:06
-
-
Save chapinb/f09b626f3326b519bcec to your computer and use it in GitHub Desktop.
FLH
This file contains 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
import os | |
import hashlib | |
input_path = '' # Type the full path here, must be directory | |
output_path = '' # Type output path here, must be file | |
if not os.path.is_dir(input_path): quit() | |
if not os.path.is_file(output_path): quit() | |
list_of_entries = [] | |
for root, entries, subs in os.walk(input_path): | |
for entry in entries: | |
sha1 = hashlib.sha1() | |
md5 = hashlib.md5() | |
full_path = os.path.abspath(entry) | |
buff = open(full_path, 'rb').read() | |
md5_hash = md5.update(buff) | |
sha1_hash = sha1.update(buff) | |
list_of_entries.append(full_path + ',' + md5_hash.hexdigest() + ',' + sha1_hash.hexdigest()) | |
fout = open(output_path, 'w') | |
fout.write('FilePath,MD5,SHA1') | |
for entry in list_of_entries: | |
fout.write(entry) | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment