//把十六进制的编码转为原码
function asciiHex2native(strAscii) { var output = ""; var posFrom = 0; var posTo = strAscii.indexOf("\x", posFrom); while (posTo >= 0) { output += strAscii.substring(posFrom, posTo); var s=""; s=strAscii.substr(posTo, 4).replace("\x","") var arr=s.split(""), n=arr.length,k=0, s=0 for(var i=0;i<n;i++){ k=n-i-1; var a=arr[i].toLocaleLowerCase(); if(a=="a"){a=10;} else if(a=="b"){a=11;} else if(a=="c"){a=12;} else if(a=="d"){a=13;} else if(a=="e"){a=14;} else if(a=="f"){a=15;} s+=(a)*Math.pow(16,k); } output += String.fromCharCode(s); posFrom = posTo + 4; posTo = strAscii.indexOf("\x", posFrom); } output+=strAscii.substring(posFrom); return ascii2native(output); } //把正常的ascii编码转为原码 function ascii2native(strAscii) { var output = ""; var posFrom = 0; var posTo = strAscii.indexOf("\u", posFrom); while (posTo >= 0) { output += strAscii.substring(posFrom, posTo); output += toChar(strAscii.substr(posTo, 6)); posFrom = posTo + 6; posTo = strAscii.indexOf("\u", posFrom); } output += strAscii.substr(posFrom); return output; }
function toChar(str) { if (str.substr(0, 2) != "\u") return str; var code = 0; for (var i=2; i<str.length; i++) { var cc = str.charCodeAt(i); if (cc >= 0x30 && cc <= 0x39) cc = cc - 0x30; else if (cc >= 0x41 && cc <= 0x5A) cc = cc - 0x41 + 10; else if (cc >= 0x61 && cc <= 0x7A) cc = cc - 0x61 + 10; code <<= 4; code += cc; } if (code < 0xff) return str; return String.fromCharCode(code); }
如下一段加密的代码:
var FF={"x48x6Fx6Dx65":{"x55x72x6C":document["x55x52x4C"],"x54x70x6C":"x64x65x66x61x6Cx75x74","x43x68x61x6Ex6Ex65x6C":"","x47x65x74x43x68x61x6Ex6Ex65x6C":function (_0xa267x1){if(_0xa267x1=="x31"){return "x76x6Fx64";} ;if(_0xa267x1=="x32"){return "x6Ex65x77x73";} ;if(_0xa267x1=="x33"){return "x73x70x65x63x69x61x6C";} ;} ,"x4Ax73":function (){this["x43x68x61x6Ex6Ex65x6C"]=this.GetChannel(Sid);if($("x23x77x64")["x6Cx65x6Ex67x74x68"]>0){$key="u8F93u5165u5F71u7247u540Du79F0u6216u4E3Bu6F14u540Du79F0";if($("x23x77x64")["x76x61x6C"]()==""){$("x23x77x64")["x76x61x6C"]($key);} ;$("x23x77x64")["x66x6Fx63x75x73"](function (){if($("x23x77x64")["x76x61x6C"]()==$key){$("x23x77x64")["x76x61x6C"]("");} ;} );$("x23x77x64")["x62x6Cx75x72"](function (){if($("x23x77x64")["x76x61x6C"]()==""){$("x23x77x64")["x76x61x6C"]($key);} ;} );} ;$("x23x66x61x76")["x63x6Cx69x63x6B"](function (){var _0xa267x2=window["x6Cx6Fx63x61x74x69x6Fx6E"]["x68x72x65x66"];try{window["x65x78x74x65x72x6Ex61x6C"]["x61x64x64x46x61x76x6Fx72x69x74x65"](_0xa267x2,document["x74x69x74x6Cx65"]);} catch(err){try{window["x73x69x64x65x62x61x72"]["x61x64x64x50x61x6Ex65x6C"](document["x74x69x74x6Cx65"],_0xa267x2,"");}
转码后的结果为
var FF={"Home":{"Url":document["URL"],"Tpl":"defalut","Channel":"","GetChannel":function (_0xa267x1){if(_0xa267x1=="1"){return "vod";} ;if(_0xa267x1=="2"){return "news";} ;if(_0xa267x1=="3"){return "special";} ;} ,"Js":function (){this["Channel"]=this.GetChannel(Sid);if($("#wd")["length"]>0){$key="输入影片名称或主演名称";if($("#wd")["val"]()==""){$("#wd")["val"]($key);} ;$("#wd")["focus"](function (){if($("#wd")["val"]()==$key){$("#wd")["val"]("");} ;} );$("#wd")["blur"](function (){if($("#wd")["val"]()==""){$("#wd")["val"]($key);} ;} );} ;$("#fav")["click"](function (){var _0xa267x2=window["location"]["href"];try{window["external"]["addFavorite"](_0xa267x2,document["title"]);} catch(err){try{window["sidebar"]["addPanel"](document["title"],_0xa267x2,"");}