-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgarble-alpha.py
60 lines (39 loc) · 1.13 KB
/
garble-alpha.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
52
53
54
55
56
57
58
59
60
'''
-=by Cjsah=-
混淆 + 乱序 + 转码
注: 此文件还没写完, 请勿使用, 后果自负
'''
import random, string, json
file = "zh_cn.json"
strs = string.digits + string.ascii_letters
def get_key():
tmp = ''
for j in range(10): # key长度
tmp += random.choice(strs)
return tmp
with open(file, "r", encoding="utf8")as f:
text = json.loads(f.read())
keys = []
for i in range(len(text)):
key = get_key()
while True: # 判断key是否重复
if key in keys:
key = get_key()
else:
break
keys.append(key)
newjson = {}
for index, key in enumerate(text): # 生成新json
newjson[keys[index]] = eval(repr(str(text[key].encode("unicode_escape"), encoding="utf8")).replace('\\\\', '\\'))
finaljson = {}
ran = []
for i, j in enumerate(newjson): # 打乱顺序
keys = list(newjson.keys())
while True:
r = random.randint(0, len(newjson) - 1)
if r not in ran:
break
ran.append(r)
finaljson[keys[r]] = newjson[keys[r]]
with open("new_" + file, "w+")as f: # 写入
f.write(json.dumps(finaljson, indent=4))