网站开发人员开发好网页在网上发布后,经常遇到自己辛苦开发好的静态页面被别人轻易的copy去。这时候就需要我们对网站采取一些加密措施,其中有一个方式:加密js文件!对静态页面(html)加载的js引用文件进行加密,一般加密的js文件都是对网页中效果影响很大的,否则网页被copy,别人删除加密文件即可。
例如我对index.html文件引用的anime.js文件16进制加密后如下:
var _0xf513=["\x2E\x61\x6E\x69\x6D","\x73\x63\x72\x6F\x6C\x6C","\x72\x65\x73\x69\x7A\x65","\x68\x65\x69\x67\x68\x74","\x73\x63\x72\x6F\x6C\x6C\x54\x6F\x70","\x74\x6F\x70","\x6F\x66\x66\x73\x65\x74","\x65\x71","\x61\x6E\x69\x6D\x2D\x73\x68\x6F\x77","\x61\x64\x64\x43\x6C\x61\x73\x73","\x65\x61\x63\x68","\x64\x6F\x6D\x61\x69\x6E","\x61\x64\x61\x73\x68\x75\x6F\x2E\x63\x6F\x6D","\x69\x6E\x64\x65\x78\x4F\x66","\x31\x32\x37\x2E\x30\x2E\x30\x2E\x31","\x6C\x6F\x63\x61\x6C\x68\x6F\x73\x74","\u8BE5\u6A21\u677F\u5C1A\u672A\u6388\u6743\u6B64\u7AD9\u4F7F\u7528\x2C\u8BF7\u8D2D\u4E70\u6388\u6743","\x68\x72\x65\x66","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x64\x65\x64\x65\x35\x38\x2E\x63\x6F\x6D"];
$(function(){var _0x6415x1=$(_0xf513[0]);setTimeout(function(){$(window)[_0xf513[1]](function(){_0x6415x2()});$(window)[_0xf513[2]](function(){_0x6415x2()});_0x6415x2()},6);function _0x6415x2(){var _0x6415x3=$(window)[_0xf513[3]]();var _0x6415x4=$(window)[_0xf513[4]]();_0x6415x1[_0xf513[10]](function(_0x6415x5){if(_0x6415x4+ _0x6415x3> _0x6415x1[_0xf513[7]](_0x6415x5)[_0xf513[6]]()[_0xf513[5]]+ 100){_0x6415x1[_0xf513[7]](_0x6415x5)[_0xf513[9]](_0xf513[8])}})}});$ym= document[_0xf513[11]];if($ym[_0xf513[13]](_0xf513[12])< 0&& $ym[_0xf513[13]](_0xf513[14])< 0&& $ym[_0xf513[13]](_0xf513[15])< 0){alert(_0xf513[16]);location[_0xf513[17]]= _0xf513[18]}
分析:
第一段相当于一个数组,数组名称是“ _0xf513”,中括号里的值例如”\x2E\x61\x6E\x69\x6D”都是数组中的一个值;而这些每个值都是一个字符串被进行过16进制转换的。例如:”.anim”==”\x2E\x61\x6E\x69\x6D”
第二段:把原本的jquery中的固定变量用上面的数组值代替:数组调用变量的方法_0xf513[17]:表示调用数组_0xf513的第18个值!
备注:上面16进制可以通过网站https://www.unphp.net进行转换,转换的源码如下:
var _0xf513=[".anim","scroll","resize","height","scrollTop","top","offset","eq","anim-show","addClass","each","domain","adashuo.com","indexOf","127.0.0.1","localhost","\u8BE5\u6A21\u677F\u5C1A\u672A\u6388\u6743\u6B64\u7AD9\u4F7F\u7528,\u8BF7\u8D2D\u4E70\u6388\u6743","href","http://www.dede58.com"];