JS eval(function(p,a,c,k,e,r){e=function(c)加、解密
1 <script>
2 a=62;
3 function encode() {
4 var code = document.getElementById('code').value;
5 code = code.replace(/[ ]+/g, '');
6 code = code.replace(/'/g, "\'");
7 var tmp = code.match(/ (w+) /g);
8 tmp.sort();
9 var dict = [];
10 var i, t = '';
11 for(var i=0; i<tmp.length; i++) {
12 if(tmp[i] != tb) 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 code2 = code.replace(/^eval/, '');
36 //alert(code);
37 document.getElementById('code').value = eval(code2);
38 }
39 </script>
40
41 <textarea id=code cols=80 rows=20>
42 </textarea>
43
44
45 <input type=button onclick=encode() value=编码>
46 <input type=button onclick=run() value=执行>
47 <input type=button onclick=decode() value=解码>
作者:tbw
补充:综合编程 , 安全编程 ,