Skip to content

Instantly share code, notes, and snippets.

@chapinb
Created May 4, 2015 01:06
Show Gist options
  • Save chapinb/f09b626f3326b519bcec to your computer and use it in GitHub Desktop.
Save chapinb/f09b626f3326b519bcec to your computer and use it in GitHub Desktop.
FLH
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