最近看了个js日历,里面用到了加密,看了下,自己也模仿做加密,现在只能加密一般的javascript语句
<!DOCTYPE html> <html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <body> <textarea id=v1 rows="8" cols="80">alert('a');</textarea> <br /> <button onclick="myFunction()">加密</button> <button onclick="fan()">翻译代码</button> <button onclick="doit()">执行加密代码</button> <br /> <textarea id=v2 rows="8" cols="80"></textarea> <p id="demo"></p> <script> //Base64^3 var key="TkRSRFN6VTBUMlkxY2s5cE5scExWRFZaSzJZMWNUSk5ORFJEVEVOMWJWbDBUMjFaY3l0dGFIVjFiVUZvZFZkdGJXVnRZWFoxWlhCMEt5czRha05FYTNWdmVtOW9OMUJ2ZGpWcWEzVmhTR3QxU1VScmRWb3piSEp4ZG1wblNVbExOa2wxYkRaSlR6azFUSEZITmt3Mkt6WmFhVEEyV21sNk5UVkRSemMzZVUxSlQxZHJjV1ZYWTNOUGJVUjJaVmRqY1U5VE5HZFBZVTlxVDFNMGNtVlBRV2RuY205MllXNXZkbkJZY0hVMFZHeDFTak50YVVwcWIyMXhibXh6UzFSMmRrbDNaelpaUTFFMlltMHZOVGQxVURWaWJUQTJTWFZ0TlhCNWNUVk1lVkkwTkVORFEzVlhRblIxWVdsd2RWZHJjV1ZsYkc1MVlVOXBUMlZ6Y0hWcGRtZFBLemhxUTBSdWJXSjJiRzVhZG05b04xUnVjR0V6YjNOTGFtOXRXbFJyZGpZM2FtZEpTVXMxTmxkbE5tSTJXalpNVTJZMVduVXJOVmxsTmpWeVUySTFja013TnpkNVRVbFBWemx4WlZkSWNFOXBhR3hQVXpWd2RXVnBjQ3RUTm10bGJVaHFUMDlCWjJkeWJHMDJSR3hyWWpOd2J6UTNiR3RKTjIxMlNsUnRhVXBFYld4dlpuWjJTWGRuTmxsSFFqVTFVM2sxWVZkSU5scGxielZNZFU4MWNUSnJOV0ZsVERRMFEwTkRkVk0wWjA5WFRtY3JWMFp4SzFkT1oyVlhPV3NyWVZoMGRWZEpkSFVyT0dwR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Vk0wYVdWWFJtY3JaVzV5SzJGV2MwOWhTV3RQVjBaeVpXVTJjWFVyT0dwRFJHeHdTMjVzYmt4RWJXNUxjbTFwU2tSdGJrbHVhM1ZKUkc1clNXSnFaMGxKU3paTEt6TTJTMlZETlhFeVRUWlpaVTAxTjBzck5XSTJkVFpMSzBFM04zbE5TVTl0Wkc1MVlWbHlLMmt3Y0U5VE5uVjFhVTl4SzFNNGIwOVROR3AxVDBGblp6MDk="; function myFunction() { var obj=document.getElementById("v1"); var str=obj.value; var res=""; for(var i=str.length-1;i>=0;i--) { res+="0x"+(str.charCodeAt(i)^key.charCodeAt(i)).toString(16)+(i>0?",":""); } document.getElementById("v2").value=res; } function fan() { var obj=document.getElementById("v2"); var str=obj.value; var arr=str.split(","); var res=""; for(var i=0;i<arr.length;i++) { if(!!arr[i]) res+=String.fromCharCode((arr[i]^key.charCodeAt(i))); } document.getElementById("demo").innerHTML=res; } function doit() { var obj=document.getElementById("v2"); var str=obj.value; var arr=str.split(","); var res=""; for(var i=arr.length-1;i>=0;i--) { if(!!arr[i]) res+=String.fromCharCode(arr[i]^key.charCodeAt(arr.length-i-1)); } eval(res); } </script> </body> </html>
暂时先写这么多,后续我还会再次增加加密解密的其他功能的。
JS加密解密第二版
今天是2015-11-21 星期六,在家里没啥事,又把前面的加密解密函数进行了整理,发出来,方便以后使用,上次的主要偏向于功能方面,这次偏向于应用方面,下面看给出代码以及我的使用说明。
<!DOCTYPE html> <html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JS加密JS原代码段</title> <body> JS原代码段: <br /> <textarea id=v1 rows="8" cols="80"> alert('aa'); alert("bb");</textarea> <br /> <label><input type="checkbox" value="hex" id="opt1" />生成测试加密的代码</label> <br /> <button onclick="myEncode()">加密</button> <button onclick="fan()">翻译</button> <button onclick="doit()">执行加密代码</button> <button onclick="doDocodeJS()">生成加密后的解密函数</button> <br /> <textarea id=v2 rows="8" cols="80"></textarea><br /> <textarea id="demo" rows="8" cols="80"></textarea> <script> var arrBase=new Array(); //在正式应用时,最好都使用数组统一管理密钥 //Base64^3 var key="TkRSRFN6VTBUMlkxY2s5cE5scExWRFZaSzJZMWNUSk5ORFJEVEVOMWJWbDBUMjFaY3l0dGFIVjFiVUZvZFZkdGJXVnRZWFoxWlhCMEt5czRha05FYTNWdmVtOW9OMUJ2ZGpWcWEzVmhTR3QxU1VScmRWb3piSEp4ZG1wblNVbExOa2wxYkRaSlR6azFUSEZITmt3Mkt6WmFhVEEyV21sNk5UVkRSemMzZVUxSlQxZHJjV1ZYWTNOUGJVUjJaVmRqY1U5VE5HZFBZVTlxVDFNMGNtVlBRV2RuY205MllXNXZkbkJZY0hVMFZHeDFTak50YVVwcWIyMXhibXh6UzFSMmRrbDNaelpaUTFFMlltMHZOVGQxVURWaWJUQTJTWFZ0TlhCNWNUVk1lVkkwTkVORFEzVlhRblIxWVdsd2RWZHJjV1ZsYkc1MVlVOXBUMlZ6Y0hWcGRtZFBLemhxUTBSdWJXSjJiRzVhZG05b04xUnVjR0V6YjNOTGFtOXRXbFJyZGpZM2FtZEpTVXMxTmxkbE5tSTJXalpNVTJZMVduVXJOVmxsTmpWeVUySTFja013TnpkNVRVbFBWemx4WlZkSWNFOXBhR3hQVXpWd2RXVnBjQ3RUTm10bGJVaHFUMDlCWjJkeWJHMDJSR3hyWWpOd2J6UTNiR3RKTjIxMlNsUnRhVXBFYld4dlpuWjJTWGRuTmxsSFFqVTFVM2sxWVZkSU5scGxielZNZFU4MWNUSnJOV0ZsVERRMFEwTkRkVk0wWjA5WFRtY3JWMFp4SzFkT1oyVlhPV3NyWVZoMGRWZEpkSFVyT0dwRFJHeHdTM0pzYUdGNmJHbExSRzFwU2tScmRVbFFiR3BaU0d0MWIzcHFaMGxKU3paWlEzVTFUSEZQTlhKSFNqVk1kV28xWW5sbk5XRXlVVFZ2YVM4M04zbE5TVTlUTkdkUFYwNW5aVmRHY1N0WGVHZFBVelIxZFdWNWRuVnBTblYxVDBGblozSnNhRmxxY0c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VlWbHlLMmt3Y0U5VE5uVjFhVTl4SzFNNGIwOVROR3AxVDBGblp6MDk="; key="9876543210zyxwvutsrqponmlkjihgfedcbaABCDEFGHIJKLMNOPQRSTUVWXYZ"; //Base64^2 var baseKey="VFdWdVoxRnBZVzVu"; baseKey=[0x56,0x46,0x64,0x57,0x64,0x56,0x6f,0x78,0x52,0x6e,0x42,0x5a,0x56,0x7a,0x56,0x75]; arrBase=[key,baseKey]; //测试使用,用于生成baseKey的十六进制数组 var t1="",num="abc"; //用于测试时生成的加密代码,可以被翻译回去 for(var i=0;i<baseKey.length;i++) t1+="0x"+baseKey.charCodeAt(i).toString(16)+","; document.getElementById("v2").value=t1; //加密js语句块的函数,①用于测试使用,②用正式环境的加密 function myEncode() { //num=document.getElementById("opt1").checked?"":"1"; var obj=document.getElementById("v1"); var str=obj.value; var s_arr=str.split(' '); var keyLength=parseInt(key.length/s_arr.length); var res=""; for(var i=0;i<s_arr.length;i++) { if(num) { res+="["; //②逆向加密,测试时可以关闭 for(var j=0,l=s_arr[i].length-1;j<s_arr[i].length;j++) //②逆向加密 res+="0x"+(s_arr[i].charCodeAt(j)^key.charCodeAt(i*keyLength+l--%keyLength)).toString(16)+(j<s_arr[i].length-1?",":""); //②逆向加密 res+="]"+(i<s_arr.length-1?",":""); //②逆向加密,测试可以请关闭 } else { for(var j=0,l=0;j<s_arr[i].length;j++) //①顺序加密 res+="0x"+(s_arr[i].charCodeAt(j)^key.charCodeAt(i*keyLength+l++%keyLength)).toString(16)+(j<s_arr[i].length-1?",":""); //①顺序加密 } res+=i<s_arr.length-1?" ":""; //①② } document.getElementById("v2").value=res; } //解密,反编译加密后的代码,全部使用①的代码进行解密,一般用于测试 function fan() { var obj=document.getElementById("v2"); var str=obj.value; var o_arr=str.split(" "); var keyLength=parseInt(key.length/o_arr.length); var res=""; for(var i=0;i<o_arr.length;i++) { var t_arr=o_arr[i].split(","); for(var j=0,l=0;j<t_arr.length;j++) { if(!!t_arr[j]) res+=String.fromCharCode((t_arr[j]^key.charCodeAt(i*keyLength+l++%keyLength))); } res+=" "; } document.getElementById("demo").innerText=res; } //执行加密代码, function doit() { var obj=document.getElementById("v2"); var str=obj.value; var o_arr=str.replace(/([)*(],)*(])*/ig,"").split(" "); for(var i=0;i<o_arr.length;i++) o_arr[i]=o_arr[i].split(","); eval(myDecode(o_arr)); } //解密函数 function myDecode() { var pwArr = arguments[0]; var argLength=arguments.length; var keyLength=parseInt(key.length/pwArr.length); var res=""; if(argLength=="1") for(var i=0;i<pwArr.length;i++) { var t_arr=pwArr[i]; if(num) { for(var j=0,l=t_arr.length-1;j<t_arr.length;j++) //②逆向解密 if(t_arr[j]!=="") res+=String.fromCharCode(t_arr[j]^key.charCodeAt(i*keyLength+l--%keyLength)); //②逆向解密 } else { for(var j=0,l=0;j<t_arr.length;j++) //①顺序解密 if(t_arr[j]!=="") res+=String.fromCharCode(t_arr[j]^key.charCodeAt(i*keyLength+l++%keyLength)); //①顺序解密 } } else { var index=arguments[1]; var t_arr=pwArr[index]; if(num) { for(var j=0,l=t_arr.length-1;j<t_arr.length;j++) //②逆向解密 if(t_arr[j]!=="") res+=String.fromCharCode(t_arr[j]^key.charCodeAt(index*keyLength+l--%keyLength)); //②逆向解密 } else { for(var j=0,l=0;j<t_arr.length;j++) //①顺序解密 if(t_arr[j]!=="") res+=String.fromCharCode(t_arr[j]^key.charCodeAt(index*keyLength+l++%keyLength)); //①顺序解密 } } return res; } /**************************************** * * * 以下用于对解密函数再加密的函数 * * * * * ****************************************/ //加密"加密的函数" function _000(pw) { var pn=""; for (var k=0;k<pw.length;k++) pn+="0x"+(pw.charCodeAt(k)+arrBase[1][k%arrBase[1].length]).toString(16)+(k<(pw.length-1)?",":""); return pn; } //解密加密的函数 function _999(pw) { var pn=""; for (var k=0;k<pw.length;k++) pn+=String.fromCharCode(pw[k]-arrBase[1][k%arrBase[1].length]); return pn; } //一般用在正式环境的时候,解密加密后的js代码,由解密函数myDecode简化而来 function decodeJS() { var res=''; var pwArr = arguments[0]; var index=arguments[1]; var keyLength=parseInt(arrBase[0].length/pwArr.length); var t_arr=pwArr[index]; for(var j=0,l=t_arr.length-1;j<t_arr.length;j++) if(t_arr[j]!=='') res+=String.fromCharCode(t_arr[j]^arrBase[0].charCodeAt(index*keyLength+l--%keyLength)); console.log(res); return res; } //decodeJS函数的压缩版,只是函数名区分大小写了 //function DecodeJS(){var res='';var pwArr=arguments[0];var index=arguments[1];var keyLength=parseInt(key.length/pwArr.length);var t_arr=pwArr[index];for(var j=0,l=t_arr.length-1;j<t_arr.length;j++){if(t_arr[j]!==''){res+=String.fromCharCode(t_arr[j]^key.charCodeAt(index*keyLength+l--%keyLength))}}return res}; function DecodeJS(){var res='';var pwArr=arguments[0];var index=arguments[1];var keyLength=parseInt(arrBase[0].length/pwArr.length);var t_arr=pwArr[index];for(var j=0,l=t_arr.length-1;j<t_arr.length;j++)if(t_arr[j]!=='')res+=String.fromCharCode(t_arr[j]^arrBase[0].charCodeAt(index*keyLength+l--%keyLength));return res} //把解密函数进行加密 function doDocodeJS() { document.getElementById("demo").value=_000(DecodeJS.toString()); } //console.log(_000("function f(x){alert(x);}"));//测试生成的加密代码 var d=[0xbc,0xbb,0xd2,0xba,0xd8,0xbf,0xde,0xe6,0x72,0xd4,0x6a,0xd2,0x7f,0xf5,0xb7,0xe1,0xbb,0xb8,0xd8,0x7f,0xdc,0x7f,0xaa,0xf5]; //console.log(_999(d));//测试解密,对加密后函数生成的加密代码 //console.log("test................."); </script> </body> </html>
使用说明:
本程序主要是由eval去执行代码,使用前期准备的JS代码段要求符合eval的使用规范以及注意事项,不懂的可以参考我博客前面几期的相关文章说明。
本次演示使用简单的根据当前日期算第几周程序,是随便找我以前的一个blogs文章中的程序:当前是本月第几周,程序代码如下:
var getMonthWeek = function(a, b, c) { var date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate(); return Math.ceil((d + 6 - w) / 7); //① }; var getYearWeek = function(a, b, c) { var date1 = new Date(a, parseInt(b) - 1, c), //② date2 = new Date(a, 0, 1), d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000); //③ return Math.ceil((d + ((date2.getDay() + 1) - 1)) / 7); }; today = new Date(); var y = today.getYear(); var m = today.getMonth() + 1; var d = today.getDate(); document.write("今天是"+ m + "月的第 " + getMonthWeek(y, m, d) + " 周"); //④ document.write("<br /><br />"+today.getHours()+":"+ today.getMinutes()+":"+ today.getSeconds());
程序很简单,大家应该都能看懂,我就不解释了,主要是加密其中的①②③④语句,下面具体说说加密使用的步骤:
1:把需要加密的JS代码段整理出来,如果是函数或多条语句,最好是每个单独执行的代码段压缩下,整理成每行是一个执行单元的语句。
这样的好处是一:方便后续的执行,二:大大减少加密后的代码。
由于我也把解密函数进行加密,所以预留了两行(后面会用到)。
Math.ceil((d + 6 - w) / 7); new Date(a, parseInt(b) - 1, c) Math.round((date1.valueOf() - date2.valueOf()) / 86400000); "今天是"+ m+ "月的第 "+ getMonthWeek(y, m, d)+ " 周" alert('aaa'); alert("bbb");
2:整理好的代码段放入“JS原代码段”的输入框中,按“加密”按钮,生成加密后的代码数字。生成后的代码数组如下:
1 [0x7e,0x55,0x41,0x5e,0x19,0x5b,0x5c,0x59,0x5d,0x1a,0x1b,0x50,0x15,0x1d,0x17,0xe,0x19,0x1d,0x11,0x45,0x1a,0x14,0x1a,0x16,0x0,0x11,0x2], 2 [0x14,0x14,0x5,0x53,0x30,0x14,0x2,0x12,0x50,0x18,0x56,0x51,0x2,0x12,0x6,0x6,0x13,0x3e,0x16,0xd,0x52,0x13,0x5b,0x53,0x59,0x55,0x47,0x5b,0x58,0x1a,0x53], 3 [0x25,0x8,0x1e,0x3,0x42,0x1f,0x1,0x1a,0x1e,0x3,0x40,0x41,0xe,0xa,0x18,0x8,0x5f,0x41,0x6,0x6,0x4,0x1c,0xf,0x24,0xa,0x45,0x47,0x4f,0x5d,0x47,0xc,0x8,0x1e,0xe,0x5e,0x43,0x18,0xe,0x1c,0x12,0xd,0x26,0xc,0x43,0x45,0x44,0x4e,0x40,0x50,0x5f,0x5e,0x5d,0x5a,0x5b,0x5c,0x5d,0x5e,0x46,0x4b], 4 [0x40,0x4ea9,0x594d,0x664a,0x44,0x6f,0x63,0x2f,0x6a,0x41,0x40,0x676b,0x76e0,0x7b49,0x46,0x66,0x68,0x62,0x26,0x4,0x16,0x2e,0xb,0xb,0x12,0x2c,0x14,0x27,0x24,0xa,0x4a,0x1a,0x48,0x45,0xb,0x68,0x63,0x26,0x68,0x4a,0x42,0x41,0x44,0x540d,0x44], 5 [0x26,0x2a,0x20,0x3c,0x39,0x64,0x6c,0x2b,0x28,0x29,0x60,0x6f,0x7e], 6 [0x30,0x3c,0x2a,0x2a,0x23,0x7e,0x77,0x36,0x31,0x30,0x73,0x79,0x74]
3:点击“生成加密后的解密函数”按钮,生成加密后的解密函数:
[0xbc,0xbb,0xd2,0xba,0xd8,0xbf,0xde,0xe6,0x72,0xb2,0xa7,0xbd,0xc5,0xde,0xbb,0xbf,0xa9,0x6e,0x8d,0xd2,0xda,0xb7,0xe1,0x98,0xc4,0xd3,0xb5,0x97,0x7d,0xa1,0x91,0xeb,0xb7,0xb8,0x84,0xc7,0xdb,0x97,0xe1,0xea,0x8f,0xcf,0xb4,0xc1,0xcb,0xe7,0xbb,0xe3,0xca,0xb9,0xbf,0x87,0xc1,0x91,0xe5,0xd9,0xc4,0x8e,0xab,0xc8,0xba,0xdf,0xce,0xb2,0xb7,0xb8,0xcb,0xcc,0xd1,0xbb,0xdd,0xec,0xc5,0xc9,0x73,0xb7,0x91,0xf0,0xb7,0xe7,0x76,0xb1,0xc9,0xd0,0xb0,0xbb,0xdd,0xdf,0xc6,0xd6,0x7f,0xca,0xb7,0xec,0xc9,0xda,0x9f,0xb4,0xd8,0x7f,0xc5,0xc8,0xe1,0xba,0xb3,0xe1,0xa7,0xb5,0x86,0xd7,0x84,0xe1,0xbb,0xb4,0xcb,0xcb,0xcc,0x85,0xdf,0xef,0x93,0xe0,0xb4,0x88,0xc2,0xdf,0xc4,0xdc,0xca,0xae,0x8d,0x92,0xda,0xb7,0xe1,0x98,0xc6,0xcd,0xa3,0xcc,0xc8,0xb7,0xc6,0xec,0x97,0xb8,0xd6,0xb2,0xcd,0xc4,0xd3,0xdd,0xca,0xcb,0x7d,0xc0,0xc5,0xec,0x7e,0xeb,0xb7,0xb8,0x84,0xc1,0xa1,0x86,0x9b,0xe4,0x8f,0xe2,0xa1,0xbb,0xc8,0xec,0x84,0xe1,0xbb,0xb4,0xcb,0xcb,0xcc,0x83,0xa0,0xb3,0xbc,0xaa,0xb6,0xb9,0xb7,0xec,0xc8,0xa3,0xc2,0xab,0xd2,0xbe,0xd8,0xbe,0xaa,0xe2,0x7d,0x99,0x6b,0xc3,0xbc,0xa2,0xca,0xd4,0xb7,0xb8,0xd6,0xb2,0xce,0xb3,0x90,0xb5,0x8f,0x95,0x69,0x83,0xc8,0xdf,0xc9,0xa0,0x93,0x99,0xd8,0xc9,0xcd,0xc4,0xd6,0xa6,0xb8,0xe0,0xb1,0xc7,0x99,0xe2,0xb7,0xe7,0x99,0xb5,0xc8,0xbc,0x8c,0xca,0xce,0xd9,0xc4,0xe0,0x9d,0xc4,0xb3,0xd8,0xb7,0xe7,0xc8,0x88,0xc5,0xca,0xc9,0xb1,0x9f,0xd5,0x80,0xd1,0xaa,0xbb,0xc8,0xbd,0xc5,0xd9,0xbb,0x87,0xd8,0x7f,0xcd,0xc4,0xd3,0xdd,0xca,0x98,0xad,0xbf,0xcf,0xc6,0xbb,0xe3,0xbd,0xba,0xcc,0x82,0xd0,0x83,0x9c,0x9d,0xbd,0xd3,0xbb,0xa6,0xbb,0xe8,0xbd,0xe9,0xbe,0x6f,0x8d,0x92,0xd6,0xbb,0xe3,0xed,0xc4,0xdc,0x62,0xcc,0xbb,0xed,0xd3]
4:把第三步生成的代码替换第二步中的第6行的数组,最后生成的如下代码:
[0x7e,0x55,0x41,0x5e,0x19,0x5b,0x5c,0x59,0x5d,0x1a,0x1b,0x50,0x15,0x1d,0x17,0xe,0x19,0x1d,0x11,0x45,0x1a,0x14,0x1a,0x16,0x0,0x11,0x2], [0x14,0x14,0x5,0x53,0x30,0x14,0x2,0x12,0x50,0x18,0x56,0x51,0x2,0x12,0x6,0x6,0x13,0x3e,0x16,0xd,0x52,0x13,0x5b,0x53,0x59,0x55,0x47,0x5b,0x58,0x1a,0x53], [0x25,0x8,0x1e,0x3,0x42,0x1f,0x1,0x1a,0x1e,0x3,0x40,0x41,0xe,0xa,0x18,0x8,0x5f,0x41,0x6,0x6,0x4,0x1c,0xf,0x24,0xa,0x45,0x47,0x4f,0x5d,0x47,0xc,0x8,0x1e,0xe,0x5e,0x43,0x18,0xe,0x1c,0x12,0xd,0x26,0xc,0x43,0x45,0x44,0x4e,0x40,0x50,0x5f,0x5e,0x5d,0x5a,0x5b,0x5c,0x5d,0x5e,0x46,0x4b], [0x40,0x4ea9,0x594d,0x664a,0x44,0x6f,0x63,0x2f,0x6a,0x41,0x40,0x676b,0x76e0,0x7b49,0x46,0x66,0x68,0x62,0x26,0x4,0x16,0x2e,0xb,0xb,0x12,0x2c,0x14,0x27,0x24,0xa,0x4a,0x1a,0x48,0x45,0xb,0x68,0x63,0x26,0x68,0x4a,0x42,0x41,0x44,0x540d,0x44], [0x26,0x2a,0x20,0x3c,0x39,0x64,0x6c,0x2b,0x28,0x29,0x60,0x6f,0x7e], [0xbc,0xbb,0xd2,0xba,0xd8,0xbf,0xde,0xe6,0x72,0xb2,0xa7,0xbd,0xc5,0xde,0xbb,0xbf,0xa9,0x6e,0x8d,0xd2,0xda,0xb7,0xe1,0x98,0xc4,0xd3,0xb5,0x97,0x7d,0xa1,0x91,0xeb,0xb7,0xb8,0x84,0xc7,0xdb,0x97,0xe1,0xea,0x8f,0xcf,0xb4,0xc1,0xcb,0xe7,0xbb,0xe3,0xca,0xb9,0xbf,0x87,0xc1,0x91,0xe5,0xd9,0xc4,0x8e,0xab,0xc8,0xba,0xdf,0xce,0xb2,0xb7,0xb8,0xcb,0xc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xad,0xbf,0xcf,0xc6,0xbb,0xe3,0xbd,0xba,0xcc,0x82,0xd0,0x83,0x9c,0x9d,0xbd,0xd3,0xbb,0xa6,0xbb,0xe8,0xbd,0xe9,0xbe,0x6f,0x8d,0x92,0xd6,0xbb,0xe3,0xed,0xc4,0xdc,0x62,0xcc,0xbb,0xed,0xd3]
5:然后把密钥、加密代码、解密函数等拷贝到你的程序中
var arrBase=[ "9876543210zyxwvutsrqponmlkjihgfedcbaABCDEFGHIJKLMNOPQRSTUVWXYZ", [0x56,0x46,0x64,0x57,0x64,0x56,0x6f,0x78,0x52,0x6e,0x42,0x5a,0x56,0x7a,0x56,0x75]]; var pw=[ [0x7e,0x55,0x41,0x5e,0x19,0x5b,0x5c,0x59,0x5d,0x1a,0x1b,0x50,0x15,0x1d,0x17,0xe,0x19,0x1d,0x11,0x45,0x1a,0x14,0x1a,0x16,0x0,0x11,0x2], [0x14,0x14,0x5,0x53,0x30,0x14,0x2,0x12,0x50,0x18,0x56,0x51,0x2,0x12,0x6,0x6,0x13,0x3e,0x16,0xd,0x52,0x13,0x5b,0x53,0x59,0x55,0x47,0x5b,0x58,0x1a,0x53], [0x25,0x8,0x1e,0x3,0x42,0x1f,0x1,0x1a,0x1e,0x3,0x40,0x41,0xe,0xa,0x18,0x8,0x5f,0x41,0x6,0x6,0x4,0x1c,0xf,0x24,0xa,0x45,0x47,0x4f,0x5d,0x47,0xc,0x8,0x1e,0xe,0x5e,0x43,0x18,0xe,0x1c,0x12,0xd,0x26,0xc,0x43,0x45,0x44,0x4e,0x40,0x50,0x5f,0x5e,0x5d,0x5a,0x5b,0x5c,0x5d,0x5e,0x46,0x4b], [0x40,0x4ea9,0x594d,0x664a,0x44,0x6f,0x63,0x2f,0x6a,0x41,0x40,0x676b,0x76e0,0x7b49,0x46,0x66,0x68,0x62,0x26,0x4,0x16,0x2e,0xb,0xb,0x12,0x2c,0x14,0x27,0x24,0xa,0x4a,0x1a,0x48,0x45,0xb,0x68,0x63,0x26,0x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8,0xbe,0xaa,0xe2,0x7d,0x99,0x6b,0xc3,0xbc,0xa2,0xca,0xd4,0xb7,0xb8,0xd6,0xb2,0xce,0xb3,0x90,0xb5,0x8f,0x95,0x69,0x83,0xc8,0xdf,0xc9,0xa0,0x93,0x99,0xd8,0xc9,0xcd,0xc4,0xd6,0xa6,0xb8,0xe0,0xb1,0xc7,0x99,0xe2,0xb7,0xe7,0x99,0xb5,0xc8,0xbc,0x8c,0xca,0xce,0xd9,0xc4,0xe0,0x9d,0xc4,0xb3,0xd8,0xb7,0xe7,0xc8,0x88,0xc5,0xca,0xc9,0xb1,0x9f,0xd5,0x80,0xd1,0xaa,0xbb,0xc8,0xbd,0xc5,0xd9,0xbb,0x87,0xd8,0x7f,0xcd,0xc4,0xd3,0xdd,0xca,0x98,0xad,0xbf,0xcf,0xc6,0xbb,0xe3,0xbd,0xba,0xcc,0x82,0xd0,0x83,0x9c,0x9d,0xbd,0xd3,0xbb,0xa6,0xbb,0xe8,0xbd,0xe9,0xbe,0x6f,0x8d,0x92,0xd6,0xbb,0xe3,0xed,0xc4,0xdc,0x62,0xcc,0xbb,0xed,0xd3]]; function _999(pw){var pn="";for(var k=0;k<pw.length;k++)pn+=String.fromCharCode(pw[k]-arrBase[1][k%arrBase[1].length]);return pn} eval(_999(pw[pw.length-1]));
6:把程序中需要替换的①②③④语句替换成解密语句DecodeJS(pw,0)并执行解密代码,参考如下:
//return Math.ceil((d + 6 - w) / 7); //① return eval(DecodeJS(pw,0)); //document.write("今天是"+ m + "月的第 " + getMonthWeek(y, m, d) + " 周"); //④ document.write(eval(DecodeJS(pw,3)));
好了,再次运行你的程序,完美执行。
另外,有什么需要注意说明,我后续也会补上来。
注意:
1:在JS原代码段的输入框中,进来不要有空格行和回车行等空行,因为空行也会参与加密代码的运算中。
2:生成解密函数的加密代码可以单独使用,或放到前面生成的加密代码段数组中,前提是加密代码段数组中必须提前要有占位行,如我上面的替换代码。
说明:以上代码为自己整理,转载请注明出处。