紧急求这个功能的Java代码,
例如把这个js代码:
function test(){alert('Hello world!')};
test();
加密结果: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}('2 3(){1(\'0 4!\')}; 3();',62,5,'Hello|alert|function|test|world'.split('|'),0,{}))
另请问,我已经集成了Yahoo YUIcompressor对js代码进行压缩,它有上面效果的加密功能吗?
例如把这个js代码:
function test(){alert('Hello world!')};
test();
加密结果: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}('2 3(){1(\'0 4!\')}; 3();',62,5,'Hello|alert|function|test|world'.split('|'),0,{}))
另请问,我已经集成了Yahoo YUIcompressor对js代码进行压缩,它有上面效果的加密功能吗?
是混淆压缩的,没有加密
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="utf-8" />
<meta name="robots" content="all" />
<title>Javascript Packer Decoder</title>
<style type="text/css">
<!--
#PackerDecoder{margin:50px auto;width:960px;overflow:hidden;text-align:center;}
-->
</style>
</head>
<body>
<h1 align="center">Javascript Packer Decoder</h1>
<div id="PackerDecoder">
<textarea id="code" cols="80" rows="20"></textarea><br />
<input type="button" id="encode" value="加密" />
<input type="button" id="runcode" value="执行" />
<input type="button" id="decode" value="解码" />
</div>
<div id="footer" style="width:400px;margin:0 auto;">Copyright © 2008-2009 <a href="http://www.yaohaixiao.com/">yaohaixiao.com</a>, All right reserved.</div>
<script type="text/javascript">
<!--
(function(){
var a = 62, D = document, btnEncode = D.getElementById('encode'), btnRun = D.getElementById('runcode'), btnDecode = D.getElementById('decode');
function encode(){
var jsCode = D.getElementById('code').value;
jsCode = jsCode.replace(/[\r\n]+/g, '');
jsCode = jsCode.replace(/'/g, "\\'");
var tmp = jsCode.match(/\b(\w+)\b/g);
tmp.sort();
var dict = [];
var i, t = '';
for (var i = 0; i < tmp.length; i++) {
if (tmp[i] != t) {
dict.push(t = tmp[i]);
}
}
var len = dict.length;
var ch;
for (i = 0; i < len; i++) {
ch = num(i);
jsCode = jsCode.replace(new RegExp('\\b' + dict[i] + '\\b', 'g'), ch);
if (ch == dict[i])
dict[i] = '';
}
D.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}(" + "'" + jsCode + "'," + a + "," + len + ",'" + dict.join('|') + "'.split('|'),0,{}))";
}
function num(c){
return (c < a ? '' : num(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36));
}
function run(){
eval(D.getElementById('code').value);
}
function decode(){
var jsCode = D.getElementById('code').value;
jsCode = jsCode.replace(/^eval/, '');
D.getElementById('code').value = eval(jsCode);
}
btnEncode.onclick = encode;
btnRun.onclick = run;
btnDecode.onclick = decode;
})();
//-->
</script>
</body>
</html>