eval(function(p,a,c,k,e,d){e=function(c)加解密

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 5     <title>Document</title>
 6 </head>
 7 <body>
 8     <script> 
 9 a=62; 
10 function encode() { 
11 var code = document.getElementById('code').value; 
12 code = code.replace(/[
]+/g, ''); 
13 code = code.replace(/'/g, "\'"); 
14 var tmp = code.match(/(w+)/g); 
15 tmp.sort(); 
16 var dict = []; 
17 var i, t = ''; 
18 for(var i=0; i<tmp.length; i++) { 
19 if(tmp[i] != t) dict.push(t = tmp[i]); 
20 } 
21 var len = dict.length; 
22 var ch; 
23 for(i=0; i<len; i++) { 
24 ch = num(i); 
25 code = code.replace(new RegExp('\b'+dict[i]+'\b','g'), ch); 
26 if(ch == dict[i]) dict[i] = ''; 
27 } 
28 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}(" 
29 + "'"+code+"',"+a+","+len+",'"+ dict.join('|')+"'.split('|'),0,{}))"; 
30 } 
31 
32 function num(c) { 
33 return(c<a?'':num(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36)); 
34 } 
35 
36 function run() { 
37 eval(document.getElementById('code').value); 
38 } 
39 
40 function decode() { 
41 var code = document.getElementById('code').value; 
42 code = code.replace(/^eval/, ''); 
43 document.getElementById('code').value = eval(code); 
44 } 
45 </script> 
46 
47 
48 <textarea id='code' cols=80 rows=20></textarea>
49 <br> 
50 <input type=button onclick=encode() value=编码> 
51 <input type=button onclick=run() value=执行> 
52 <input type=button onclick=decode() value=解码> 
53 
54 </body>
55 </html>
原文地址:https://www.cnblogs.com/php-qiuwei/p/9564308.html