-
Notifications
You must be signed in to change notification settings - Fork 0
/
encrypt.py
38 lines (28 loc) · 931 Bytes
/
encrypt.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
33
34
35
36
37
38
#!/usr/bin/python3
from colorama import Fore, Style, Back
from cryptography.fernet import Fernet
print(Fore.YELLOW + '''
.-""-.
/ .--. \\
/ / \\ \\
| | | |
| |.-""-.|
///`.::::.`\\
||| ::/ \\:: ;
||; ::\__/:: ;
\\\ '::::' /
`=':-..-'`
LeT's
EncRyPt
''' + Style.RESET_ALL)
filekey_raw = input(Fore.CYAN + "Where is your key?\n" + Style.RESET_ALL)
with open(filekey_raw, 'rb') as filekey:
key = filekey.read()
fernet = Fernet(key)
fileraw = input(Fore.CYAN + "\nWhat file do you want to encrypt?\n" + Style.RESET_ALL)
with open(fileraw, 'rb') as file:
original = file.read()
encrypted = fernet.encrypt(original)
with open(fileraw, 'wb') as encrypted_file:
encrypted_file.write(encrypted)
print('\nYour file has been successfully ' + Fore.YELLOW + 'encrypted' + Style.RESET_ALL + '!')