<html>
<script language="VB" runat="server">Private Sub onDecrypt(ByVal sender As Object, ByVal e As EventArgs)
Response.Write(Decrypt(test.value))
End SubPrivate Function Decrypt(str)
Dim chrArr as char()=str.ToCharArray()
dim i as Integer
Dim ret as String=""
For i=0 to test.value.length-1 step 2
ret=ret & ChrW(AscW(chrArr(i))-AscW(chrArr(i+1)))
Next
Decrypt=ret
End Function
</script>
</head>
<body>
<form runat="server">
<input type=text id=test value=中文Abc runat="server">
<input type=submit runat="server" onclick="test.value=Encrypt(test.value)" onserverclick="onDecrypt">
</form>
<script>
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;
}
</script>
</body>
</html>
<script language="VB" runat="server">Private Sub onDecrypt(ByVal sender As Object, ByVal e As EventArgs)
Response.Write(Decrypt(test.value))
End SubPrivate Function Decrypt(str)
Dim chrArr as char()=str.ToCharArray()
dim i as Integer
Dim ret as String=""
For i=0 to test.value.length-1 step 2
ret=ret & ChrW(AscW(chrArr(i))-AscW(chrArr(i+1)))
Next
Decrypt=ret
End Function
</script>
</head>
<body>
<form runat="server">
<input type=text id=test value=中文Abc runat="server">
<input type=submit runat="server" onclick="test.value=Encrypt(test.value)" onserverclick="onDecrypt">
</form>
<script>
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;
}
</script>
</body>
</html>
这段代码出错:
Dim chrArr as char()
Char类型最大值只能是65535
如果我放入好多中文字符,那么出现溢出错误~~!