项目

一般

简介

解码.html

Java Script/HTML5 解码&加密工具 - 石 路, 2015-12-26 14:51

下载 (1.5 KB)

 
1
<script> 
2
a=62; 
3
function encode() { 
4
var code = document.getElementById('code').value; 
5
code = code.replace(/[\r\n]+/g, ''); 
6
code = code.replace(/'/g, "\\'"); 
7
var tmp = code.match(/\b(\w+)\b/g); 
8
tmp.sort(); 
9
var dict = []; 
10
var i, t = ''; 
11
for(var i=0; i<tmp.length; i++) { 
12
if(tmp[i] != t) dict.push(t = tmp[i]); 
13
} 
14
var len = dict.length; 
15
var ch; 
16
for(i=0; i<len; i++) { 
17
ch = num(i); 
18
code = code.replace(new RegExp('\\b'+dict[i]+'\\b','g'), ch); 
19
if(ch == dict[i]) dict[i] = ''; 
20
} 
21
document.getElementById('code').value = "eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}(" 
22
+ "'"+code+"',"+a+","+len+",'"+ dict.join('|')+"'.split('|'),0,{}))"; 
23
} 
24

25
function num(c) { 
26
return(c<a?'':num(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36)); 
27
} 
28

29
function run() { 
30
eval(document.getElementById('code').value); 
31
} 
32

33
function decode() { 
34
var code = document.getElementById('code').value; 
35
code = code.replace(/^eval/, ''); 
36
document.getElementById('code').value = eval(code); 
37
} 
38
</script> 
39

    
40

    
41
<textarea id=code cols=80 rows=20> 
42

    
43
</textarea><br> 
44
<input type=button onclick=encode() value=????> 
45
<input type=button onclick=run() value=???> 
46
<input type=button onclick=decode() value=????>