-
Notifications
You must be signed in to change notification settings - Fork 1
/
decrypter.py
51 lines (35 loc) · 1.02 KB
/
decrypter.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
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# -*- coding utf-8 -*-
import os, json, AESCrypter
with open('./config.json') as data_file:
CONFIG = json.load(data_file)
class Decrypt():
# configs
KEY = CONFIG['KEY']
path = CONFIG['TARGET_PATH']
listfiles = os.listdir(path)
def __init__(self):
files = self.generateListFiles()
self.cryptFiles(files);
def generateListFiles(self):
files = []
for f in self.listfiles:
files.append(self.path+f)
return files
def cryptFiles(self, files):
aes = AESCrypter.Init(self.KEY.encode('utf-8'));
for f in files:
res = self.getFileContent(f)
crypt = aes.decrypt(res)
self.writeToFile(f, crypt)
def getFileContent(self, file):
f = open(file, 'rb')
result = f.read();
f.close();
return result;
def writeToFile(self, file, data):
f = open(file, 'wb')
result = f.write(data);
f.close();
return 1;
Decrypt();