WEB开发网
开发学院网页设计JavaScript js文本加密及解密器 阅读

js文本加密及解密器

 2009-05-07 20:11:27 来源:WEB开发网   
核心提示:<SCRipT LANGUAGE="javaScript"><!-- Beginfunction Encrypt(theText) {output = new String;Temp = new Array();Temp2 = new Array();TextSize = theT
<SCRipT LANGUAGE="javaScript">
<!-- Begin
function Encrypt(theText) {
output = new String;
Temp = new Array();
Temp2 = new Array();
TextSize = theText.length;
for (i = 0; i < TextSize; i++) {
rnd = Math.round(Math.random() * 122) + 68;
Temp[i] = theText.charCodeAt(i) + rnd;
Temp2[i] = rnd;
}
for (i = 0; i < TextSize; i++) {
output += String.fromCharCode(Temp[i], Temp2[i]);
}
return output;
}
function unEncrypt(theText) {
output = new String;
Temp = new Array();
Temp2 = new Array();
TextSize = theText.length;
for (i = 0; i < TextSize; i++) {
Temp[i] = theText.charCodeAt(i);
Temp2[i] = theText.charCodeAt(i + 1);
}
for (i = 0; i < TextSize; i = i+2) {
output += String.fromCharCode(Temp[i] - Temp2[i]);
}
return output;
}
//  End -->
</script>
<center>
<form name=encform >
   <textarea name=box1 rows=5 cols=50>Typhoon Start Javascript Fairyland</textarea>
<p>
    <input type=button value="加密到下面文本框" >
<p>
<textarea name=box2 rows=5 cols=50></textarea>
<p>
    <input type=button value="解密到下面文本框" >
<p>
<textarea name=box3 rows=5 cols=50></textarea>
</form>
</center>

Tags:js 文本 加密

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接