-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.py
More file actions
33 lines (22 loc) · 752 Bytes
/
Copy pathdecrypt.py
File metadata and controls
33 lines (22 loc) · 752 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
import os
from cryptography.fernet import Fernet, InvalidToken # pip install cryptography
TOKEN = input("Please Enter The Token here: ")
fernet = Fernet(TOKEN)
def decrypt(file):
try:
with open(file, "rb") as my_file:
my_file_data = my_file.read()
decrypted_file_data = fernet.decrypt(my_file_data)
with open(file, "wb") as my_file:
my_file.write((decrypted_file_data))
except InvalidToken:
print("Invalid Token, please enter the real Token! ")
exit()
except Exception:
return
safe_file = ['main.py', 'token_file.key', 'decryted.py']
for file in os.listdir():
if file in safe_file:
continue
elif os.path.isfile(file):
decrypt(file)