-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtools.html
355 lines (327 loc) · 13.7 KB
/
tools.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<html>
<head>
<meta charset="utf-8" />
<style>
body {
flow: vertical;
border-spacing: 8px;
}
div {
margin: 1;
}
div.xml {
margin: 1;
flow: horizontal;
}
div.json {
margin: 1;
flow: horizontal;
}
div.edit {
margin: 1;
flow: vertical;
}
div.list {
background: white white #EFEFEF #EFEFEF;
border: 1px solid;
width: *;
height: *;
overflow: scroll-indicator;
}
plaintext {
margin: 1;
padding: 0;
flow: vertical;
behavior: plaintext;
background: #333;
border: 1px solid #333;
color: white;
overflow: auto;
font-rendering-mode: snap-pixel;
size: *;
tab-size: 4;
}
plaintext > text {
font-family: monospace;
white-space: pre-wrap;
background: white;
color: black;
margin-left: 3em;
padding-left: 4dip;
cursor: text;
display: list-item;
list-style-type: index;
list-marker-color: #aaa;
}
plaintext > text:last-child {
padding-bottom: *;
}
plaintext > text:nth-child(10n) {
list-marker-color: #fff;
}
switch {
font: system;
display: inline-block;
flow: horizontal;
width: max-content;
background: url(theme:button-normal) stretch;
prototype: Switch url(switch.tis);
}
switch > option {
margin: 2px 0;
border-right: 1px solid threedshadow;
padding: 3px 8px 4px 8px;
text-shadow: #eee 0px 1px;
}
switch > option:first-child {
margin-left: 2px
}
switch > option:last-child {
border-right: none;
margin-right: 2px
}
switch > option:hover {
color: brown;
}
switch > option:checked {
background: threedshadow;
text-shadow: none;
color: highlighttext;
}
switch:focus > option:checked {
background: highlight;
}
switch:tab-focus > option:checked {
outline: 1px dotted -2px;
}
</style>
<script type="text/tiscript">
var msg = {
A0001: "请选择配置文件目录和加密文件输出目录",
A0002: "请选择不同目录",
A0003: "请设置秘钥长度",
A0004: "处理完毕,请查看日志",
A0005: "秘钥长度超过最大阈值2048,请重新输入",
A0006: "秘钥长度最小为256,请重新输入",
A0007: "请输入Xml字符串",
A0008: "请输入Json字符串",
A0009: "请输入包名",
A0010: "请输入struct类型名",
N0001: "错误提示"
};
$(button.selector1).onClick = function() {
var fn = view.selectFolder();
if (fn) $(.path1).value = fn;
};
$(button.selector2).onClick = function() {
var fn = view.selectFolder();
if (fn) $(.path2).value = fn;
};
$(#btn).onClick = function() {
this.attributes["disabled"] = "disabled"
var path1 = $(.path1).value
var path2 = $(.path2).value
if (path1 == "" || path2 == "") {
view.msgbox(#alert, msg.A0001, msg.N0001);
this.attributes.remove("disabled");
return;
}
if (path1 == path2) {
view.msgbox(#alert, msg.A0002, msg.N0001);
this.attributes.remove("disabled");
return;
}
if ($(form).value.radioGroup == 4 && $(form).value.bitwd == "") {
view.msgbox(#alert, msg.A0003, msg.N0001);
this.attributes.remove("disabled");
return;
}
if ($(form).value.radioGroup == 4) {
if ($(form).value.bitwd > 2048) {
view.msgbox(#alert, msg.A0005, msg.N0001);
this.attributes.remove("disabled");
return;
}
if ($(form).value.bitwd < 256) {
view.msgbox(#alert, msg.A0006, msg.N0001);
this.attributes.remove("disabled");
return;
}
}
var res = view.encrypt($(form).value);
if (res["cmd"] == "done") {
view.msgbox(#alert, msg.A0004, msg.N0001);
}
};
$(form).on("change", function() {
var radioGroupValue = this.value.radioGroup;
if (radioGroupValue == 1 || radioGroupValue == 2 || radioGroupValue == 3) {
$(#pass).style["display"] = "block";
$(#bit).style["display"] = "none";
$(#result).style["display"] = "block";
$(#pubkey).style["display"] = "none";
$(#prikey).style["display"] = "none";
$(#inputPubkey).style["display"] = "none";
$(#inputPrikey).style["display"] = "none";
$(#inputLabel).style["display"] = "none";
$(#result).html = "";
} else if (radioGroupValue == 4) {
$(#pass).style["display"] = "none";
$(#bit).style["display"] = "block";
$(#result).style["display"] = "block";
$(#pubkey).style["display"] = "none";
$(#prikey).style["display"] = "none";
$(#inputPubkey).style["display"] = "none";
$(#inputPrikey).style["display"] = "none";
$(#inputLabel).style["display"] = "none";
$(#result).html = "";
} else if (radioGroupValue == 5) {
$(#pass).style["display"] = "none";
$(#bit).style["display"] = "block";
$(#result).style["display"] = "none";
$(#pubkey).style["display"] = "block";
$(#prikey).style["display"] = "block";
$(#inputPubkey).style["display"] = "none";
$(#inputPrikey).style["display"] = "none";
$(#inputLabel).style["display"] = "none";
$(#result).html = "";
} else if (radioGroupValue == 6) {
$(#pass).style["display"] = "none";
$(#bit).style["display"] = "none";
$(#result).style["display"] = "block";
$(#pubkey).style["display"] = "none";
$(#prikey).style["display"] = "none";
$(#inputPubkey).style["display"] = "block";
$(#inputPrikey).style["display"] = "none";
$(#inputLabel).style["display"] = "block";
$(#result).html = "";
} else if (radioGroupValue == 7) {
$(#pass).style["display"] = "none";
$(#bit).style["display"] = "none";
$(#result).style["display"] = "block";
$(#pubkey).style["display"] = "none";
$(#prikey).style["display"] = "none";
$(#inputPubkey).style["display"] = "none";
$(#inputPrikey).style["display"] = "block";
$(#inputLabel).style["display"] = "block";
$(#result).html = "";
}
});
function enable() {
$(#btn).attributes.remove("disabled");
};
$(switch).on("change", function() {
if (this.value == "Encrypt") {
$(#Encrypt).style["display"] = "block";
$(#Xml).style["display"] = "none";
$(#Json).style["display"] = "none";
} else if (this.value == "Xml") {
$(#Encrypt).style["display"] = "none";
$(#Xml).style["display"] = "block";
$(#Json).style["display"] = "none";
} else if (this.value == "Json") {
$(#Encrypt).style["display"] = "none";
$(#Xml).style["display"] = "none";
$(#Json).style["display"] = "block";
}
});
$(#convert2j).onClick = function() {
if ($(#source).value==""){
view.msgbox(#alert, msg.A0008, msg.N0001);
return;
}
if ($(#package).value==""){
view.msgbox(#alert, msg.A0009, msg.N0001);
return;
}
if ($(#structname).value==""){
view.msgbox(#alert, msg.A0010, msg.N0001);
return;
}
view.json2struct();
}
$(#convert2x).onClick = function() {
if ($(#xmlsource).value==""){
view.msgbox(#alert, msg.A0007, msg.N0001);
return;
}
view.xml2struct();
}
</script>
</head>
<body>
<switch>
<option value="Encrypt">xorm配置文件加密</option>
<option value="Json">json转struct</option>
<option value="Xml">xml转struct</option>
</switch>
<div id="Encrypt" style="display:block;height: *;">
<div>
<form>
<div>
<div>配置文件存放目录
<input type="text" name="path1" class="path1" size="80" readonly/><button class="selector1">…</button></div>
<div>加密文件输出目录
<input type="text" name="path2" class="path2" size="80" readonly/><button class="selector2">…</button></div>
加密算法
<br/>
<input type="radio" name="radioGroup" value="1" checked="checked">AES</input>
<input type="radio" name="radioGroup" value="2">DES</input>
<input type="radio" name="radioGroup" value="3">TripleDes</input>
<input type="radio" name="radioGroup" value="4">RSA</input>
<input type="radio" name="radioGroup" value="5">生成RSA秘钥</input>
<input type="radio" name="radioGroup" value="6">RSA公钥加密</input>
<input type="radio" name="radioGroup" value="7">RSA私钥加密</input>
<input type="button" id="btn" class="selector3" value="加密" /><br/>
</div>
<div id="pass" style="display:block">密码<input type="text" name="passwd" class="passwd" size="30" /></div>
<div id="bit" style="display:none">
秘钥长度<input type="text" name="bitwd" class="bitwd" size="8" filter="0~9" maxlength="4" />
<input type="radio" name="rsaMode" value="1" checked="checked">公钥加密私钥解密模式</input>
<input type="radio" name="rsaMode" value="2">私钥加密公钥解密模式</input>
</div>
</form>
</div>
<div id="inputLabel" style="display:none">请输入秘钥</div>
<plaintext id="inputPubkey" style="display:none" tab-size=4></plaintext>
<plaintext id="inputPrikey" style="display:none" tab-size=4></plaintext>
<div id="result" style="display:true" class="list"></div>
<plaintext id="pubkey" style="display:none" tab-size=4 readonly></plaintext>
<plaintext id="prikey" style="display:none" tab-size=4 readonly></plaintext>
</div>
<div id="Json" style="display:none;height: *;width: *;" class="edit">
<div style="width: *;">
包名:
<input type="text" id="package" size="30" />
struct类型名:
<input type="text" id="structname" size="30" />
<input type="button" id="convert2j" class="selector3" value="转换" />
</div>
<div style="height: *;width: *;" class="json">
<div style="height: *;width: *;" class="edit">
请输入JSON字符串
<textarea id="source" style="height: *;width: *;"></textarea>
</div>
<div style="height: *;width: *;" class="edit">
结果
<textarea id="json2struct" style="height: *;width: *;"></textarea>
</div>
</div>
</div>
<div id="Xml" style="display:none;height: *;" class="edit">
<div style="width: *;">
<input type="button" id="convert2x" class="selector3" value="转换" />
</div>
<div style="height: *;width: *;" class="xml">
<div style="height: *;width: *;" class="edit">
请输入Xml字符串
<textarea id="xmlsource" style="height: *;width: *;"></textarea>
</div>
<div style="height: *;width: *;" class="edit">
结果
<textarea id="xml2struct" style="height: *;width: *;"></textarea>
</div>
</div>
</div>
</body>
</html>