-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChecksum.py
32 lines (25 loc) · 1.09 KB
/
Checksum.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
import subprocess
import os
directory_items = {}
algorithm_list = ["MD5", "SHA1", "SHA256"]
for i, j in enumerate(os.scandir()):
directory_items[i+1] = j
print("Files in Directory: ")
for i in list(directory_items.keys()):
print(f'\t{i}. {directory_items.get(i).name}')
file_number = int(input("Enter the file number: "))
file = directory_items.get(file_number)
print("\nHashing Algorithms: ")
for i, j in enumerate(algorithm_list):
print(f'\t{i+1}. {j}')
algorithm = int(input("\nEnter the Algorithm Number: "))
user_hashvalue = input("Enter the hashvalue (Press enter to skip): ")
response = subprocess.run(f"certutil -hashfile \"{file.name}\" {algorithm_list[algorithm-1]}", stdout=subprocess.PIPE)
real_hashvalue = response.stdout.decode('utf-8').splitlines()[1]
print();
print(f"Generated {algorithm_list[algorithm-1]} value:", real_hashvalue)
if(user_hashvalue != ""):
print("User:", user_hashvalue)
# print(real_hashvalue == user_hashvalue)
print("\nChecksums are Matching!" if real_hashvalue.lower() == user_hashvalue.lower() else "Checksums are not Matching")
hold = input()