Last active
September 16, 2019 16:36
-
-
Save Ra1d7/55233e8b959227bc1d2b0d1109cec5da to your computer and use it in GitHub Desktop.
Calculates the checksum of a file or all files in a folder (you can edit the algorithm used easily by replacing each hashlib.sha256 with whatever algorithm you like)
This file contains hidden or 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 hashlib | |
import os | |
while True: | |
s = hashlib.sha256() | |
path = r'{}'.format(input('Path to file or Folder: \033[7m')) | |
print('\033[0m') | |
try: | |
with open(path, "rb") as f: | |
for chunk in iter(lambda: f.read(4096), b""): | |
s.update(chunk) | |
print('#'*70) | |
print(' '*10,end='') | |
print('File ' + path.replace('\\\\','\\')) | |
print('#'*70) | |
print('[+] \033[32m'+s.hexdigest()+'\033[0m') | |
except: | |
print('#'*70) | |
print(' '*10,end='') | |
print('Folder ' + path.replace('\\\\','\\')) | |
print('#'*70) | |
for file in os.listdir(path): | |
try: | |
with open(path +'\\'+file, "rb") as f: | |
for chunk in iter(lambda: f.read(4096), b""): | |
e=hashlib.sha256() | |
e.update(chunk) | |
print('[+] \033[32m'+e.hexdigest()+'\033[0m',file) | |
except Exception as e: | |
print(f'\033[31mError Could Not Process {file}\033[0m ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment