<script language="JavaScript">
function test(str){
var ww='';
for(i=0;i<str.length;i++)
ww+=String.fromCharCode(str.charCodeAt(i)<127?str.charCodeAt(i)+65248:str.charCodeAt(i));
return ww
}
function test2(str){
var ww='';
for(i=0;i<str.length;i++)
ww+=String.fromCharCode((str.charCodeAt(i)>=65248)&&(str.charCodeAt(i)<65375)?str.charCodeAt(i)-65248:str.charCodeAt(i));
return ww
}
function ec(txt)
{
var wri="";
for(var x=0;x<txt.length;x++)
{
var s=escape(txt.charAt(x));
if(s==txt.charAt(x))
{
wri+=txt.charAt(x);
}
else
{
wri+=s.substring(2,s.length);
}
}
return wri;
}
function unec(txt)
{
var wri="";
for(var x=0;x<txt.length;x=x+4)
{
wri+=unescape("%u"+txt.charAt(x)+txt.charAt(x+1)+txt.charAt(x+2)+txt.charAt(x+3));
}
return wri;
}
function zip(txt)
{
var wri="";
for(var x=0;x<txt.length;x=x+2)
{
var c1=txt.charCodeAt(x)+"";
var c2=txt.charCodeAt(x+1)+"";
if(c1.length==c2.length)
{
}
else if(c1.length>c2.length)
{
for(var y=0;y<c1.length-c2.length;y++)
{
c2="0"+c2;
}
}
else if(c1.length<c2.length)
{
for(var y=0;y<c2.length-c1.length;y++)
{
c1="0"+c1;
}
}
wri+=String.fromCharCode(c1+""+c2);
status=Math.round(x/(txt.length-2)*100)+"%";
}
return wri;
}
function unzip(txt)
{
var wri="";
for(var x=0;x<txt.length;x++)
{
var c=txt.charCodeAt(x)+"";
wri+=String.fromCharCode(c.substring(0,c.length/2))+String.fromCharCode(c.substring(c.length/2,c.length));
status=Math.round(x/(txt.length-2)*100)+"%";
}
var w="";
for(var x=4;x<wri.length;x=x+12)
{
w+=unescape("%u"+wri.charAt(x)+wri.charAt(x+1)+wri.charAt(x+2)+wri.charAt(x+3))+unescape("%u"+wri.charAt(x+4)+wri.charAt(x+5)+wri.charAt(x+6)+wri.charAt(x+7));
status=Math.round(x/(txt.length-2)*100)+"%";
}
var s=w.split("%u");
return s[0];
}
</script>
<center>
<form name=encform οnsubmit="return false;">
<textarea name=box1 rows=5 cols=50>在此输入文本来显示简单的加密</textarea>
<p>
<input type=button value="把文本框一中的文件加密显示到文本框二中" onClick="this.form.box2.value=zip(ec(test(this.form.box1.value)));">
<p>
<textarea name=box2 rows=5 cols=50></textarea>
<p>
<input type=button value="把文本框二中的文本解密到文本框三中显示" onClick="this.form.box3.value=test2(unzip(unec(this.form.box2.value)));">
<p>
<textarea name=box3 rows=5 cols=50></textarea>
</form>
</center>
function test(str){
var ww='';
for(i=0;i<str.length;i++)
ww+=String.fromCharCode(str.charCodeAt(i)<127?str.charCodeAt(i)+65248:str.charCodeAt(i));
return ww
}
function test2(str){
var ww='';
for(i=0;i<str.length;i++)
ww+=String.fromCharCode((str.charCodeAt(i)>=65248)&&(str.charCodeAt(i)<65375)?str.charCodeAt(i)-65248:str.charCodeAt(i));
return ww
}
function ec(txt)
{
var wri="";
for(var x=0;x<txt.length;x++)
{
var s=escape(txt.charAt(x));
if(s==txt.charAt(x))
{
wri+=txt.charAt(x);
}
else
{
wri+=s.substring(2,s.length);
}
}
return wri;
}
function unec(txt)
{
var wri="";
for(var x=0;x<txt.length;x=x+4)
{
wri+=unescape("%u"+txt.charAt(x)+txt.charAt(x+1)+txt.charAt(x+2)+txt.charAt(x+3));
}
return wri;
}
function zip(txt)
{
var wri="";
for(var x=0;x<txt.length;x=x+2)
{
var c1=txt.charCodeAt(x)+"";
var c2=txt.charCodeAt(x+1)+"";
if(c1.length==c2.length)
{
}
else if(c1.length>c2.length)
{
for(var y=0;y<c1.length-c2.length;y++)
{
c2="0"+c2;
}
}
else if(c1.length<c2.length)
{
for(var y=0;y<c2.length-c1.length;y++)
{
c1="0"+c1;
}
}
wri+=String.fromCharCode(c1+""+c2);
status=Math.round(x/(txt.length-2)*100)+"%";
}
return wri;
}
function unzip(txt)
{
var wri="";
for(var x=0;x<txt.length;x++)
{
var c=txt.charCodeAt(x)+"";
wri+=String.fromCharCode(c.substring(0,c.length/2))+String.fromCharCode(c.substring(c.length/2,c.length));
status=Math.round(x/(txt.length-2)*100)+"%";
}
var w="";
for(var x=4;x<wri.length;x=x+12)
{
w+=unescape("%u"+wri.charAt(x)+wri.charAt(x+1)+wri.charAt(x+2)+wri.charAt(x+3))+unescape("%u"+wri.charAt(x+4)+wri.charAt(x+5)+wri.charAt(x+6)+wri.charAt(x+7));
status=Math.round(x/(txt.length-2)*100)+"%";
}
var s=w.split("%u");
return s[0];
}
</script>
<center>
<form name=encform οnsubmit="return false;">
<textarea name=box1 rows=5 cols=50>在此输入文本来显示简单的加密</textarea>
<p>
<input type=button value="把文本框一中的文件加密显示到文本框二中" onClick="this.form.box2.value=zip(ec(test(this.form.box1.value)));">
<p>
<textarea name=box2 rows=5 cols=50></textarea>
<p>
<input type=button value="把文本框二中的文本解密到文本框三中显示" onClick="this.form.box3.value=test2(unzip(unec(this.form.box2.value)));">
<p>
<textarea name=box3 rows=5 cols=50></textarea>
</form>
</center>