标签:style blog io ar color os sp for java
//加密 function MyEncrypt(txt) { var sb = ""; var rand = 0; for (var i=0;i<txt.length;i++) { item=txt.charCodeAt(i); rand = Math.floor(Math.random()*item); sb+=(pad((item - rand).toString(16),2) + pad(rand.toString(16),2)); } return sb; } //解密 function MyDencrypt(txt) { var sb = ""; var hexArray = new Array(255); var len = txt.length / 2; for (var i = 0; i < len; i++) { hexArray[i] = txt.substr(i * 2, 2); } for (var i = 0; i < len; i++) { if (i % 2 == 0) sb+=(String.fromCharCode(parseInt(hexArray[i], 16) + parseInt(hexArray[i + 1], 16))); } return sb; } //补零 function pad(num, n) { return Array(n-(‘‘+num).length+1).join(0)+num; }
标签:style blog io ar color os sp for java
原文地址:http://www.cnblogs.com/mahatmasmile/p/4154558.html