임의의 문자열을 사용하여 변수를 대체하는 등 원본 코드를 난독화하고 자신이 작성한 코드를 보호합니다. 이는 다른 사람이 직접 표절하는 데 도움이 되지 않습니다 코드 복사 코드는 다음과 같습니다. <br><!-- <BR>/**//**//** <BR>** <BR>===================================== == ========================= <BR>===================== === ============= <BR>** 클래스 이름: CLASS_CONFUSION <BR>** 기능: JS 난독화 <BR>** 예: <BR> ------ ---- ------------------- <BR>------------------------------- <br><br> var xx = new CLASS_CONFUSION(코드); <br><br> document.getElementById("display").innerHTML = <BR>xx.confusion() <br><br> --------- - --------------------- <BR> ------------------- <BR>* * 작성자: ttyp <BR>** 이메일: ttyp@21cn.com <BR>** 날짜: 2006-3-20 <BR>** 버전: 0.12 <BR>** <BR>====== ==== ============================================= ==== == <BR>===================================<BR>**<🎝>* <br>** <br>=== ================================================= ==========<BR>===================================<BR>** 클래스 이름: CLASS_CONFUSION <BR>** 함수: JS 난독화 <BR>** 예: <BR> ------------------------ -- --------------------- <BR>------------ ----- --------------- <BR><BR> var xx = new CLASS_CONFUSION(코드) <BR><BR> document .getElementById("display").innerHTML = <BR>xx.confusion() <BR><BR> ------- ------- ------ <BR>--------- ---------- ------------- <BR>** 작성자: ttyp <BR>** 이메일 : ttyp@21cn.com <BR> ** 날짜: 2006-3-20 <BR>** 버전: 0.12 <BR>** <BR>================ ========== ====================================<BR> ========== ========================== <BR>**/ <BR><BR>함수 CLASS_CONFUSION (코드){ <🎜> //Ha 해시테이블 클래스<🎜> function Hashtable(){ <🎜> this._hash = new Object() <🎜> this.add = function(key,value){ <🎜> if (typeof(key)!="정의되지 않음"){ <🎜> this._hash[key]=typeof <🎜>(값)==false){ ?null:value <🎜> true; ~ 삭제하세요._hash <🎜 >[key];} <🎜> this.count = function(){var i=0;for(var k in <🎜>this._hash){i ;} return i;} <🎜 > this.items = function (key){return this._hash <🎜>[key];} <🎜> this.contains = function(key){return typeof <🎜>(this._hash[key])!=" 정의되지 않음";}<BR> this.clear = function(){for(var k in <BR>this._hash){delete this._hash[k];}} <br><br> } <br><br> function VariableMap( 상위){ <BR> this.table = new Hashtable(); <BR> this.level = parent?parent.level 1:0; <BR> this.parent= 부모; <BR> this.add = function(key,value){this.table.add <BR>(key,value)}; <BR> this.items = function(key){return this.table.items <BR>(key)}; <BR> this.count = function(){return this.table.count()}; <BR> this.contains = function(key){return <BR>this.table.contains(key);} <BR> this.isParameter = false; <BR> } <br><br> this._caseSensitive = true; <br><br> //字符串转换为哈希表 <BR> this.str2hashtable = function(key,cs){ <br><br> var _key = key.split(/,/g); <BR> var _hash = new Hashtable(); <BR> var _cs = true; <br><br><BR> if(typeof(cs)=="undefine"||cs==null){ <BR> _cs = this._caseSensitive; <BR> } else { <BR> _cs = cs; <BR> } <br><br> for(var i in _key){ <BR> if(_cs){ <BR> _hash.add(_key[i]); <BR> } else { <BR> _hash.add((_key[i] "").toLowerCase()); <BR> } <br><br> } <BR> return _hash; <BR> } <br><br> //获得需要转换的代码 <BR> this._codetxt = code; <br><br> if(typeof(syntax)=="정의되지 않음"){ <BR> 구문 = ""; <BR> } <br><br> this._deleteComment = false; <BR> //是否大写敏感 <BR> this._caseSensitive = true; <BR> //得到关键字哈希表 <BR> this._keywords = this.str2hashtable <BR>("switch,case,delete,default,typeof,for,in,function,void,this, <BR>부울 ,while,if,return,new,true,false,try,catch,throw,null,el <BR>se,do,var"); <BR> this._function = this.str2hashtable("function"); <BR> this._var = "var"; <BR> this._beginBlock = "{"; <BR> this._endBlock = "}"; <br><br> this._window = this.str2hashtable <BR>("alert,escape,unescape,document,parseInt,parseFloat"); <BR> //得到内建对象哈希表 <BR> this._commonObjects = this.str2hashtable <BR>("String,Number,Boolean,RegExp,Error,Math,Date,Object,Array,Gl <BR>obal "); <BR> //得到分割字符 <BR> this._wordDelimiters= " ,.?!;:\/<>(){}[]"'rnt= - <br>|*%@#$^&"; <br> //따옴표 문자<br> this._quotation = this.str2hashtable("",'"); <br> // 줄 주석 문자 <br> this._lineComment = "//"; <br> //이스케이프 문자 <br> this._escape = "\" <br> //여러 줄 인용 시작<br> this._commentOn = "/*"; <br> //여러 줄 인용 끝<br> this._commentOff = "*/"; <br> this._execute = "eval" <br> //인용 문자<br> this._call = "."; <br> This._varpause = "="; <br> This._varContinue = "," <br> // 변수 개수 <br> this._varnum = 0; .confusion = function() { <br> var codeArr = new Array(); <br> var word_index = 0; <br> var htmlTxt = new Array(); <br><br><br> // 분할 문자 배열(단어 분할) <br> for (var i = 0; i < this._codetxt.length; i ) { <BR><BR> if (this._wordDelimiters.indexOf <br>(this._codetxt. charAt(i)) == -1) { //키워드 <br> 찾을 수 없음 if (codeArr[word_index] == null || typeof <BR>(codeArr[word_index]) == 'undefine') { <BR> codeArr[word_index] = ""; ]) != '정의되지 않음' <BR>&& codeArr[word_index].length > 0) <BR> <BR> }<br> <br> <<> var quote_opned = false; // 마크 참조 <BR> var Slash_star_comment_opned = false; // 다중 라인 메모 <BR> 🎜 标 <BR> var Slash_slash_co m promise_opned = false; 단일 메모 <BR>설명 표시<BR> var line_num = 1; //줄 번호<BR> var quote_char = ""; //인용문<BR> 태그 유형 <BR> var call_opened = <BR> var call_string = ""; <BR> var var_opened = false; <BR> var function_opened = false; <BR><BR> var var_map = new VariableMap ); <BR> var cur_var_map = var_map; <br> varexecute_opened = false <br><BR> //블록으로 표시하려면 분할 단어를 누르세요. for (var i=0; i <=word_index; i){ <BR><BR> ~ > (codeArr[i]!=this._call){ <br> htmlTxt[htmlTxt.length] = codeArr <br>[i] <BR> call_opened = <br> }<BR> call_string = ""; <BR> } <BR> } 그렇지 않으면 { <BR> if(!this.isVar(codeArr[i])){ <BR> htmlTxt[htmlTxt.length] = "["" <BR>this.toHex(call_string) ""]"; <BR> if(codeArr[i]!=this._call){ <BR> htmlTxt[htmlTxt.length] = codeArr <BR>[i]; <BR> call_opened = false; <BR> } <BR> call_string = ""; <BR> }else{ <BR> htmlTxt[htmlTxt.length] = "["" <BR>this.toHex(call_string) ""]"; <BR> } <BR> } <BR> 계속; <BR> } <br><br> //处리 공간행(由于转义带来) <BR> if(typeof(codeArr[i])=="정의되지 않음"||codeArr <BR>[i].length ==0){ <BR> 계속; <BR> } else if(codeArr[i]==" "){ <BR> htmlTxt[htmlTxt.length] = " "; <BR> } else if(codeArr[i]=="n"){ <BR> //처리 처리 <BR> } else if(codeArr[i]=="r"){ <BR> slash_slash_comment_opened = false; <BR> quote_opened = false; <BR> var_opened = false; <BR> htmlTxt[htmlTxt.length] = "rn"; <BR> line_num ; <BR> //처리 기능별 参数标记 <BR> } else if (!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&this.isFunction <BR>(코드 Arr[i])){ <BR> htmlTxt[htmlTxt.length ] = codeArr[i]; <BR> function_opened = true; <BR> } else if (!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i]=="("){ <BR> htmlTxt[htmlTxt.length] = codeArr[i] <BR> if(function_opened == true){ <BR> function_opened =false; <BR> var_opened = true; <BR> cur_var_map = new VariableMap <BR>(cur_var_ 지도); <BR> cur_var_map.isParameter = true <BR> } <BR> } if (!slash_slash_comment_opened&& ! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i]==")"){ <BR> htmlTxt[htmlTxt.length] = codeArr[i]; <BR> //处理var a = new Class(),b=new Date();类似的 <BR>问题 <BR> if(cur_var_map.isParameter){ <BR> var_opened = false; <BR> var_pause = false; <BR> } <BR> } 그렇지 않으면 (!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i]==";"){ <BR> htmlTxt[htmlTxt.length] = codeArr[i]; <BR> var_opened = false; <BR> var_pause = false; <BR> if(execute_opened){ <BR> execute_opened = false; <BR> } <BR> } else if (!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i] <BR>==this._var){ htmlTxt[htmlTxt.length] = codeArr[i]; <BR> var_opened = true; <BR> var_pause = false; <BR> } else if(!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i] <BR>==this._varPause){ <BR> htmlTxt[htmlTxt. 길이] = codeArr[i]; <BR> var_pause = true; <BR> } else if(!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i] <BR>==this._varContinue){ <BR> htmlTxt .length] = codeArr[i]; <BR> var_pause = false; <BR> } else if(!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i] <BR>==this._beginBlock){ <BR> cur_var_map = new VariableMap(cur_var_map); <BR> var_opened = false; <BR> htmlTxt[htmlTxt.length] = codeArr[i]; <BR> } else if(!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i] <BR>==this._endBlock){ <BR> cur_var_map = cur_ var_map.parent; <BR> if(cur_var_map.isParameter){ <BR> cur_var_map = cur_var_map.parent; <BR> } <BR> htmlTxt[htmlTxt.length] = codeArr[i]; <BR> //处理引用调用 <BR> } else if (!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened &&codeArr[i] <BR>==this._call){ 🎜> //判断引用(.)后면第一个是否字母货_$ <BR> if(i<word_index-1){ <BR> if(this.isVar(codeArr[i 1])) if(call_opened){ <BR> htmlTxt [htmlTxt.length] = <BR>this.toHex(call_string); <BR> } <BR> call_opened = true; <BR> }else{ <BR> htmlTxt[htmlTxt.length] = this._call; <BR> } <BR> }else{ <BR> htmlTxt[htmlTxt.length] = this._call; <BR> } <BR> //处理关键字 <BR> } 그렇지 않으면 (!slash_slash_comment_opened&& <BR>slash_star_comment_opened && !quote_opened &! & this.is키워드 <BR>(codeArr[i])){ <BR> htmlTxt[htmlTxt .length] = codeArr[i]; <BR> //////////////<BR> } else if (!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened && codeArr[i] <BR>==this._execute){ <BR> htmlTxt[htmlTxt.length] = "window["" <BR>this.to 16진수( codeArr[i]) ""]"; <BR> execute_opened = true; <BR> //window内置对象 <BR> } else if (!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened && this.isWindow <BR>(codeArr[i] )){ <BR> htmlTxt[htmlTxt.length] = "window["" <BR>this.toHex(codeArr[i]) ""]"; <BR> //处理普 通对象 <BR> } else if (!slash_slash_comment_opened&&! <BR>slash_star_comment_opened && !quote_opened && <BR>this.isCommonObject(codeArr[i ])){ <BR> htmlTxt[htmlTxt.length] = "window["" <BR>this.toHex(codeArr[i]) ""]"; <BR> //处理双引号(引号前不能为转义字符) <BR> } 그렇지 않으면 (!slash_star_comment_opened&& <BR>slash_slash_comment_opened&&this._quotation .contains(codeArr <BR>[i])){ <BR> if (quote_opened){ <BR> //是상应的引号 <BR> if(quote_char==codeArr[i]){ <BR> html Txt[htmlTxt.length] = codeArr[i]; <BR> quote_opened = false; <BR> quote_char = ""; <BR> } else { <BR> htmlTxt[htmlTxt.length] = this.toHex <BR>(codeArr[i]); <BR> } <BR> } else { <BR> htmlTxt[htmlTxt.length] = codeArr[i]; <BR> quote_opened = true; <BR> quote_char = codeArr[i]; <BR> } <BR> //处理转义字符 <BR> } else if(codeArr[i] == this._escape){ <BR> htmlTxt[htmlTxt.length] = codeArr[i]; <BR> if(i<word_index-1){ <BR> if(codeArr[i 1].charCodeAt(0) <BR>>=32&&codeArr[i 1].charCodeAt(0)<=127){ <BR> htmlTxt[htmlTxt.length] = codeArr <BR>[i 1].substr(0,1); <BR> htmlTxt[htmlTxt.length] = this.toHex <BR>(codeArr[i 1].substr(1)); <BR> i=i 1; <BR> } <BR> } <BR> //处理多行注释的开始 <BR> } else if (!slash_slash_com ment_opened && ! <BR>slash_star_comment_opened&&!quote_opened&&this.isStartWith <BR>(this._commentOn,codeArr,i) ){ <BR> slash_star_comment_opened = true; <BR> htmlTxt[htmlTxt.length] = this._commentOn; <BR> i = i this.getSkipLength(this._commentOn); <BR> //处理单行注释 <BR> } else if (!slash_slash_comment_opened && ! <BR>slash_star_comment_opened&&!quote_opened&&this.isStartWith <BR>(this._lineComment,code Arr,i)){ <BR> slash_slash_comment_opened = true; <BR> if(!this._deleteComment){ <BR> htmlTxt[htmlTxt.length] = <BR>this._lineComment; <BR> } <BR> i = i this.getSkipLength(this._lineComment); <BR> //处理忽略词 <BR> } else if (!slash_slash_comment_opened && ! <BR>slash_star_comment_opened&&!quote_opened&&this.isStartWith <BR>(this._ignore,codeArr ,i)){ <BR> slash_slash_comment_opened = true; <BR> htmlTxt[htmlTxt.length] = this._ignore; <BR> i = i this.getSkipLength(this._ignore); <BR> //관리다행注释结束 <BR> } else if (!quote_opened&&! <BR>slash_slash_comment_opened&&this.isStartWith <BR>(this._commentOff,codeArr,i)){ <BR> if (slash_star_comment_opened) slash_star_comment_opened = false; <BR> if(!this._deleteComment){ <BR> htmlTxt[htmlTxt.length] = <BR>this._commentOff; <BR> } <BR> i = i this.getSkipLength <BR>(this._commentOff); <BR> } <BR> } else { <BR> //不是 字符串中 <BR> if(!quote_opened){ //如果不是현재注释중 <BR> if(!slash_slash_comment_opened && ! <BR>slash_star_comment_opened){ <BR> /////////////////////불포함 수량 <BR> if(!var_opened){ <BR> if(this.translateVar <BR>(cur_var_map,codeArr[i])==""){ <BR> htmlTxt[htmlTxt.length] = <BR>codeArr[i]; <BR> }else{ <BR> htmlTxt[htmlTxt.length] = <BR>this.translateVar(cur_var_map,codeArr[i]); <BR> } <BR> }그렇지 않으면{ <BR> //불투정义时 <BR> if(var_pause){ <BR> if(this.translateVar <BR>(cur_var_map,codeArr[i])== ""){ <BR> htmlTxt[htmlTxt.length] = <BR>codeArr[i]; <BR> }else{ <BR> } <BR> ~ <BR> 앞에 공백이나 탭 문자 또는 쉼표가 오기 때문입니다(예: var a;var a;var a,b;). 다음과 같은 매개변수: function(a,b,c) <BR> (this.isVar(codeArr[i])&& <BR>(i>0&&codeArr[i-1]==" "||codeArr[i-1 ]=="t"||codeArr[i-1] <br>==this._varContinue||cur_var_map.isParameter)){ <br> Cur_var_map.add(codeArr <br>[i],name); <br> htmlTxt[htmlTxt.length] = <br>this.translateVar(cur_var_map,codeArr[i]); htmlTxt[htmlTxt.length] = <br>codeArr[i]; <br> <br>} } 🎜> // 댓글 <br>} else {<br> if (! This._deletecomment) {<br> htmltxt [htmltxt.length] = codearr <br> [i] <br> ~else{ <br> if(execute_opened){ <br> if(this.translateVar <br>(cur_var_map,codeArr[i])==""){ <br> htmlTxt[htmlTxt.length] = codeArr <br>[ 나]; <br> }else{ <br> htmlTxt[htmlTxt.length] = <br>this.translateVar(cur_var_map,codeArr[i]); <br> } <br> }else{ <br> htmlTxt[htmlTxt.length] = this.toHex>(codeArr[i ]); <br> } <br> } <br> } <br><br> } <br><br> return htmlTxt.join("") ; <br> } <br>this.isStartWith = function(str,code,index){ <br><br> if(typeof(str)!="undefed"&&str.length>0){ <br> var cc = 새로운 배열(); <br> for(var i=index;i<index str.length;i ){ <BR> cc[cc.length] = code[i]; <BR> } <BR> var c = cc.join(""); <BR> if(this._caseSensitive){ <BR> if(str.length>=code[index].length&&c.indexOf <br>(str)==0){ <br> return true; <br> } <br> }else{ <br> if(str.length>=code <br>[index].length&&c.toLowerCase().indexOf(str.toLowerCase()) <br>==0) { <br> true를 반환합니다. <br> } <br> } <br> false를 반환합니다. <br><br> } else { <br> false를 반환합니다. <br> } <br> } <br><br> this.isFunction = function(val){ <br> return this._function.contains(this._caseSensitive? <br>val:val.toLowerCase()); <br> } <br><br> this.isKeyword = function(val) { <br> return this._keywords.contains(this._caseSensitive? <br>val:val.toLowerCase()); <br> } <br><br> this.isWindow = function(val) { <br> return this._window.contains(this._caseSensitive? <br>val:val.toLowerCase()); <br> }<br><br> this.isCommonObject = function(val) { <br> return this._commonObjects.contains <br>(this._caseSensitive?val:val.toLowerCase()); <br> } <br><br> this.getSkipLength = function(val){ <br> var count = 0; <br> for(var i=0;i<val.length;i ){ <BR> if(this._wordDelimiters.indexOf(val.charAt(i)) <BR>>=0){ <br> 개수 ; <br> } <br> } <br> if(count>0){ <br> count=count-1; <br> } <br> 반품 횟수; <br> } <br><br> //자세히 보기 <br> for(var i=0;i<val.length;i ){ <BR> var c = val.charCodeAt(i); <BR> if(c>=0&&c<256){ <BR> str[str.length] = "\x" val.charCodeAt <BR>(i).toString(16); <BR> }else{ <BR> str[str.length] = "\u" val.charCodeAt <BR>(i).toString(16); <BR> } <BR> } <BR> return str.join(""); <BR> } <BR><BR> //获得变weight随机name <br> this.getRandName = function(){ <br> var style = parseInt(Math.random()*4); <BR> var len = parseInt(Math.random()*9) 1; <BR> var n = []; <BR><BR> this._varNum ; <br> var c = <br>"abcdefghijklmnopqrstuvwsyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$"; <BR><BR> for(var i=0;i<leni ){ <br> n[n.length] = c.charAt(parseInt(Math.random() <br>*54)); <BR> } <BR><BR> return n.join("") this._varNum; <br><br> } <br><br> //是否符合变weight命name字首规则 <br> this.isVar = function(val){ <br> return /^[a-zA-Z_$].* $/.test(val); <BR> } <BR><BR> //翻译变weight,如果返回为空则不存在此变weight <br> this.translateVar = function(node,key){ <br> if(node.contains(key)) { <BR> return node.items(key); <BR> } <BR><BR> var cn = node.parent; <br> while(cn!=null){ <br> if(cn.contains(key)){ <BR> return cn.items(key); <BR> } <BR> cn = cn.parent; <BR> } <BR> 반환 ""; <BR> } <BR><BR><br>}<br><br>함수 doConfusion(o){ <BR> var htmltxt = ""; <br><br> if (o == null){ <BR> alert("domNode가 null입니다!"); <BR> 반품; <BR> } <br><br> var _codetxt = ""; <br><br> if(typeof(o)=="object"){ <BR> switch(o.tagName){ <BR> 'TEXTAREA': <BR> '입력' <BR> _codetxt = o.값; <BR> 휴식; <BR> 케이스 "DIV": <BR> 케이스 "SPAN": <BR> _codetxt = o.innerText; <BR> 휴식; <BR> 기본값: <BR> _codetxt = o.innerHTML; <BR> 휴식; <BR> } <BR> }else{ <BR> _codetxt = o; <BR> } <br><br> var _syn = new CLASS_CONFUSION(_codetxt); <BR> htmltxt = _syn.confusion(); <BR> return htmltxt; <BR>} <br><br><BR>function go() <BR>{ <BR> var code = document.getElementById("code").value; <BR> var xx = 신규 CLASS_CONFUSION(코드); <BR> var a = new Date(); <BR> document.getElementById("display").value = xx.confusion(); <BR> alert("共꽃:" (new Date().getTime()-a.getTime()) <BR>"ms"); <BR>} <BR>//--> <br>