-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHash_Check.py
More file actions
36 lines (28 loc) · 902 Bytes
/
Hash_Check.py
File metadata and controls
36 lines (28 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import hashlib
import os
path='fileList.txt'
file_list = open(path,'w')
lists_files_old = []
lists_files_new = []
lists_files_new = os.listdir('new/')
lists_files_old = os.listdir('old/')
for filename in lists_files_new:
for filecompare in lists_files_old:
if filecompare == filename:
hasher = hashlib.md5()
with open('new/'+filename, 'rb') as f:
buf = f.read()
hasher.update(buf)
a = hasher.hexdigest()
#print filename
#print a
hasher = hashlib.md5()
with open('old/'+filecompare, 'rb') as f:
buf = f.read()
hasher.update(buf)
b = hasher.hexdigest()
#print filecompare
#print b
if a != b:
file_list.write(filecompare+'\n')
file_list.close()