首页 > js代码的加密问题

js代码的加密问题

今天在看到某网站的js代码如下

!function(e,t){function r(e){return function(t){return Object.prototype.toString.call(t)==="[object "+e+"]"}}function n(e){for(e=e.replace(N,"/"),e=e.replace(O,"$1/");e.match(U);)e=e.replace(U,"/");return e}function i(e){return e=n(e),_.test(e)?e=e.slice(0,-1):C.test(e)||(e+=".js"),e.replace(":80/","/")}function a(e,t){return D.test(e)?e:K.test(e)?(t||G).match(w)[0]+e:M.test(e)?(G.match(W)||["/"])[0]+e.substring(1):mt.base+e}function s(e,t){if(!e)return"";var r,n=e,s=mt.alias,n=e=s&&q(s[n])?s[n]:n,s=mt.paths;s&&(r=n.match(F))&&q(s[r[1]])&&(n=s[r[1]]+r[2]),r=n;var u=mt.vars;u&&-1<r.indexOf("{")&&(r=r.replace(I,function(e,t){return q(u[t])?u[t]:e})),e=a(r,t),r=e=i(e);var n=mt.map,o=r;if(n)for(s=0;s<n.length&&(o=n[s],o=R(o)?o(r)||r:r.replace(o[0],o[1]),!(o!==r));s++);return o}function u(e,t){var r,n=e.sheet;if(tt)n&&(r=!0);else if(n)try{n.cssRules&&(r=!0)}catch(i){"NS_ERROR_DOM_SECURITY_ERR"===i.name&&(r=!0)}setTimeout(function(){r?t():u(e,t)},20)}function o(){if(L)return L;if(P&&"interactive"===P.readyState)return P;for(var e=V.getElementsByTagName("script"),t=e.length-1;t>=0;t--){var r=e[t];if("interactive"===r.readyState)return P=r}}function c(e){this.uri=e,this.dependencies=[],this.exports=null,this.status=0}function f(e,t){if(x(e)){for(var r=[],n=0;n<e.length;n++)r[n]=f(e[n],t);return r}return r={id:e,refUri:t},k("resolve",r),r.uri||s(r.id,t)}function l(t,r){x(t)||(t=[t]),h(t,function(){for(var n=[],i=0;i<t.length;i++)n[i]=y(it[t[i]]);r&&r.apply(e,n)})}function h(e,t){var r=m(e);if(0===r.length)t();else{k("load",r);for(var n=r.length,i=n,a=0;n>a;a++)(function(e){function r(t){t||(t=n);var r=m(a.dependencies);0===r.length?t():b(a)?(r=pt,r.push(r[0]),T("Circular dependencies: "+r.join(" -> ")),pt.length=0,t(!0)):(ot[e]=r,h(r,t))}function n(e){!e&&a.status<lt&&(a.status=lt),0===--i&&t()}var a=it[e];a.dependencies.length?r(function(t){function r(){n(t)}a.status<ft?d(e,r):r()}):a.status<ft?d(e,r):n()})(r[a])}}function d(e,r){function n(){delete at[a],st[a]=!0,Q&&(g(e,Q),Q=t);var r,n=ut[a];for(delete ut[a];r=n.shift();)r()}it[e].status=ct;var i={uri:e};k("fetch",i);var a=i.requestUri||e;if(st[a])r();else if(at[a])ut[a].push(r);else{at[a]=!0,ut[a]=[r];var s=mt.charset;if(k("request",i={uri:e,requestUri:a,callback:n,charset:s}),!i.requested){var i=i.requestUri,o=Z.test(i),c=Y.createElement(o?"link":"script");s&&(s=R(s)?s(i):s)&&(c.charset=s);var f=c;!o||!tt&&"onload"in f?f.onload=f.onerror=f.onreadystatechange=function(){et.test(f.readyState)&&(f.onload=f.onerror=f.onreadystatechange=null,!o&&!mt.debug&&V.removeChild(f),f=t,n())}:setTimeout(function(){u(f,n)},1),o?(c.rel="stylesheet",c.href=i):(c.async=!0,c.src=i),L=c,X?V.insertBefore(c,X):V.appendChild(c),L=t}}}function p(e,r,n){if(1===arguments.length&&(n=e,e=t),!x(r)&&R(n)){var i=[];n.toString().replace(nt,"").replace(rt,function(e,t,r){r&&i.push(r)}),r=i}var a={id:e,uri:f(e),deps:r,factory:n};if(!a.uri&&Y.attachEvent){var s=o();s?a.uri=s.src:T("Failed to derive: "+n)}k("define",a),a.uri?g(a.uri,a):Q=a}function g(e,r){var n=it[e]||(it[e]=new c(e));n.status<ft&&(n.id=r.id||e,n.dependencies=f(r.deps||[],e),n.factory=r.factory,n.factory!==t&&(n.status=ft))}function v(e){function r(t){return f(t,e.uri)}function n(e){return y(it[r(e)])}if(!e)return null;if(e.status>=ht)return e.exports;e.status=ht,n.resolve=r,n.async=function(e,t){return l(r(e),t),n};var i=e.factory,i=R(i)?i(n,e.exports={},e):i;return e.exports=i===t?e.exports:i,e.status=dt,e.exports}function m(e){for(var t=[],r=0;r<e.length;r++){var n=e[r];n&&(it[n]||(it[n]=new c(n))).status<lt&&t.push(n)}return t}function y(e){var t=v(e);return null===t&&(!e||!Z.test(e.uri))&&k("error",e),t}function b(e){var t=ot[e.uri]||[];if(0===t.length)return!1;pt.push(e.uri);e:{for(e=0;e<t.length;e++)for(var r=0;r<pt.length;r++)if(pt[r]===t[e]){e=!0;break e}e=!1}if(e){for(e=pt[0],r=t.length-1;r>=0;r--)if(t[r]===e){t.splice(r,1);break}return!0}for(e=0;e<t.length;e++)if(b(it[t[e]]))return!0;return pt.pop(),!1}function $(e){var t=mt.preload,r=t.length;r?l(f(t),function(){t.splice(0,r),$(e)}):e()}function j(e){for(var t in e){var r=e[t];if(r&&"plugins"===t){t="preload";for(var n=[],s=void 0;s=r.shift();)n.push(J+"plugin-"+s);r=n}if((n=mt[t])&&S(n))for(var u in r)n[u]=r[u];else x(n)?r=n.concat(r):"base"===t&&(r=i(a(r+"/"))),mt[t]=r}return k("config",e),A}var E=e.seajs;if(!E||!E.version){var A=e.seajs={version:"2.0.0"},S=r("Object"),q=r("String"),x=Array.isArray||r("Array"),R=r("Function"),T=A.log=function(t,r){e.console&&(r||mt.debug)&&console[r||(r="log")]&&console[r](t)},B=A.events={};A.on=function(e,t){return t?((B[e]||(B[e]=[])).push(t),A):A},A.off=function(e,t){if(!e&&!t)return A.events=B={},A;var r=B[e];if(r)if(t)for(var n=r.length-1;n>=0;n--)r[n]===t&&r.splice(n,1);else delete B[e];return A};var k=A.emit=function(e,t){var r,n=B[e];if(n)for(n=n.slice();r=n.shift();)r(t);return A},w=/[^?#]*\//,N=/\/\.\//g,O=/([^:\/])\/\/+/g,U=/\/[^/]+\/\.\.\//g,C=/\?|\.(?:css|js)$|\/$/,_=/#$/,F=/^([^/:]+)(\/.+)$/,I=/{([^{]+)}/g,D=/:\//,K=/^\./,M=/^\//,W=/^.*?\/\/.*?\//,Y=document,z=location,G=z.href.match(w)[0],H=Y.getElementsByTagName("script"),H=Y.getElementById("seajsnode")||H[H.length-1],J=(H.hasAttribute?H.src:H.getAttribute("src",4)).match(w)[0]||G;A.cwd=function(e){return e?G=n(e+"/"):G};var L,P,Q,V=Y.getElementsByTagName("head")[0]||Y.documentElement,X=V.getElementsByTagName("base")[0],Z=/\.css(?:\?|$)/i,et=/^(?:loaded|complete|undefined)$/,tt=536>1*navigator.userAgent.replace(/.*AppleWebKit\/(\d+)\..*/,"$1"),rt=/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g,nt=/\\\\/g,it=A.cache={},at={},st={},ut={},ot={},ct=1,ft=2,lt=3,ht=4,dt=5;c.prototype.destroy=function(){delete it[this.uri],delete st[this.uri]};var pt=[];A.use=function(e,t){return $(function(){l(f(e),t)}),A},c.load=l,A.resolve=s,e.define=p,A.require=function(e){return(it[s(e)]||{}).exports};var gt=J,vt=gt.match(/^(.+?\/)(?:seajs\/)+(?:\d[^/]+\/)?$/);vt&&(gt=vt[1]);var mt=j.data={base:gt,charset:"utf-8",preload:[]};A.config=j;var yt,z=z.search.replace(/(seajs-\w+)(&|$)/g,"$1=1$2"),z=z+(" "+Y.cookie);if(z.replace(/seajs-(\w+)=1/g,function(e,t){(yt||(yt=[])).push(t)}),j({plugins:yt}),z=H.getAttribute("data-config"),H=H.getAttribute("data-main"),z&&mt.preload.push(z),H&&A.use(H),E&&E.args)for(H=["define","config","use"],E=E.args,z=0;z<E.length;z+=2)A[H[E[z]]].apply(A,E[z+1])}}(this);
!function(){var e=document.getElementById("container").getAttribute("data-init")||"init",s=document.getElementById("seajsnode").getAttribute("src"),o=s.lastIndexOf("?")>0?s.substring(s.lastIndexOf("?")+1):"20141111";seajs.config({alias:{jQuery:"jquery.min.js",init:"app/sInit.js",SuperSlide:"lib/jquery.SuperSlide.2.1.1.min.js",countUp:"lib/countUp.js",SmoothScroll:"lib/smoothscroll.js",imagesLoaded:"lib/imagesloaded.pkgd.min.js",Isotope:"lib/jquery.isotope.min.js",Colorbox:"lib/Colorbox/jquery.colorbox.min.js",cookie:"lib/jquery.cookie.js",json2:"lib/json2.js",util:"mod/util.js",silder:"mod/silder.js",formCheck:"mod/formCheck.js",placeholder:"mod/placeholder.js",sIndex:"app/sIndex.js",sArticle:"app/sArticle.js",sList:"app/sList.js"},map:[[/^(.*\/.*\.(?:css|js))(?:.*)$/i,"$1?"+o]],preload:["jQuery"]}),e&&seajs.use(e)}();
define("app/sInit",[],function(o){function n(){$(window).scrollTop()>500?$("#u-goTop").fadeIn():$("#u-goTop").fadeOut()}var t=/chrome/.test(navigator.userAgent.toLowerCase());t&&o.async("SmoothScroll"),$(".nav .item").hover(function(){clearTimeout(this.timer),$(this).find(".sub").show()},function(){var o=this;this.timer=setTimeout(function(){$(o).find(".sub").hide()},100)}),n(),$(window).scroll(function(){n()}),$("#u-goTop").on("click",function(){$("body,html").animate({scrollTop:0},500)})});

请大牛指导这是什么怎么加密的,加密成这样的代码还有被人解密吗?


这个不是加密
这个是代码压缩加混淆


可以用 Uglify、YUICompressor、Google Closure Complier、Packer 等工具压缩成这样,并非真正意义上的加密,如果生产 map 的话,可以反压缩

你可以用在线的 Packer 试一下
http://dean.edwards.name/packer/

【热门文章】
【热门文章】