forked from Community-A-4E/community-a4e-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_hashes.py
45 lines (34 loc) · 898 Bytes
/
check_hashes.py
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
37
38
39
40
41
42
43
44
45
import hashlib
import os
import sys
BUFF_SIZE = 65536
def main(files, useroot):
if (len(files) == 0):
print("Please supply files...")
return
root = "A-4E-C"
fm_folder = "A-4E-C/ExternalFM/FM"
print("==== Hashes ====")
for file in files:
sha1 = hashlib.sha1()
path = file
if ( useroot ):
path = os.path.join(root, file)
f = open (path, 'rb')
while True:
data = f.read(BUFF_SIZE)
if not data:
break
sha1.update(data)
f.close()
print("File: {}, SHA1: {}".format(file, sha1.hexdigest()))
if __name__ == "__main__":
args = sys.argv[1:]
files = []
useRoot = False
for arg in args:
if arg == "--use_root":
useRoot = True
else:
files.append(arg)
main(files, useRoot)