<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>呵呵文本加解密</title></head>
<body>
<script language="javascript" type="text/javascript">
var sdf3="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcde";
function textEncrypt(str)
{;var t="";var a,a1,a2,a3;var b=sdf3.split("");
for(var x=0;x<str.length;x++){a=str.charCodeAt(x)
a1=a%41;a=(a-a1)/41;a2=a%41;a=(a-a2)/41;a3=a%41;t+=b[a3]+b[a2]+b[a1]}a="z";
for(var x=0;x<t.length;x+=3){if(t.charAt(x)!="A")
{return t}a+=t.substr(x+1,2)}return a}
function textDecryption(str)
{;var a1,a2,a3,b=sdf3,d=0,t,a;
if(str.charAt(0)=="z"){t=new Array(Math.floor((str.length-1)/2))
a=t.length;for(var x=0;x<a;x++){d++;a2=b.indexOf(str.charAt(d))
d++;a3=b.indexOf(str.charAt(d))
t[x]=a2*41+a3}};
else{t=new Array(Math.floor(str.length/3))
a=t.length;for(var x=0;x<a;x++){a1=b.indexOf(str.charAt(d))
d++;a2=b.indexOf(str.charAt(d))
d++;a3=b.indexOf(str.charAt(d))
d++;t[x]=a1*1681+a2*41+a3}}
a=eval("String.fromCharCode("+t.join(',')+")");return a}
</script>
<textarea id="content" name="content" style="width:850px;border:1px solid #c5e2f2;overflow:visible;" rows="15"></textarea>
</br>
<input class="but" id="conv" type="button" value="加密 ↓" onclick="result.value=textEncrypt(content.value);"/>
<input class="but" id="res" type="button" value="解密 ↑" onclick="content.value=textDecryption(result.value)" />
</br>
<textarea id="result" name="result" style="width:850px;border:1px solid #c5e2f2;overflow:visible;" rows="15"></textarea>
</body>
</html>
评论5