-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecrypt.py
40 lines (34 loc) · 858 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
33
34
35
36
37
38
39
40
import os
from cryptography.fernet import Fernet
files1=os.listdir(os.getcwd())
cur=os.getcwd()
with open("scret.key","rb") as file1:
key1=file1.read()
key2=Fernet(key1)
# print(key2)
for file1 in files1:
if file1=="scret.key" or file1=="encrypt.py" or file1=="decrypt.py":
pass
elif os.path.isdir(file1):
for fi in os.listdir(os.chdir(file1)):
if os.path.isfile(fi):
with open(fi,"rb") as f:
ff=f.read()
new=key2.decrypt(ff)
fff=open(fi,"wb")
fff.write(new)
else:
os.chdir(cur)
with open(file1,"rb") as f:
ff=f.read()
new=key2.decrypt(ff)
with open(file1,"wb") as fff:
fff.write(new)
# else:
# pass
# os.chdir(cur)
# with open(file1,"rb") as f:
# ff=f.read()
# new=key2.encrypt(ff)
# with open(file1,"wb") as fff:
# fff.write(new)