js常用函数总结

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dreamboycx/article/details/52837129




//对字符串进行加密
function compileStr(code){    
   var c=String.fromCharCode(code.charCodeAt(0)+code.length);  
   for(var i=1;i<code.length;i++){  
   c+=String.fromCharCode(code.charCodeAt(i)+code.charCodeAt(i-1));  
   }
   return escape(c);  
}





//字符串进行解密
function uncompileStr(code){  
   code=unescape(code);  
   var c=String.fromCharCode(code.charCodeAt(0)-code.length);  
   for(var i=1;i<code.length;i++){  
   c+=String.fromCharCode(code.charCodeAt(i)-c.charCodeAt(i-1));  
   }  
   return c;  
}


猜你喜欢

转载自blog.csdn.net/dreamboycx/article/details/52837129