session.Timeout=120
function torot13(str_rot13) '将ASCII码转换为ROT13码(包括阿拉伯数字)
dim str_ascii
for i=len(str_rot13) to 1 step -1
If Asc(right(str_rot13 ,i)) > 64 And Asc(right(str_rot13 ,i)) < 91 Then
newAsc = Asc(right(str_rot13 ,i)) + 13
If newAsc > 90 Then newAsc = newAsc - 26
ElseIf Asc(right(str_rot13 ,i)) > 96 And Asc(right(str_rot13 ,i)) < 123 Then
newAsc = Asc(right(str_rot13 ,i)) + 13
If newAsc > 122 Then newAsc = newAsc - 26
Elseif Asc(right(str_rot13 ,i)) > 47 And Asc(right(str_rot13 ,i)) < 58 Then
newAsc = Asc(right(str_rot13 ,i)) + 5
If newAsc > 57 Then newAsc = newAsc - 10
Else
newAsc = Asc(right(str_rot13 ,i))
End If
str_ascii = str_ascii + chr(newAsc)
next
torot13 = str_ascii
End function
Function TenturnTwo(varNum ,varsit) '返回第一个参数的二进制形式,第二个参数决定返回字符串的位数
Dim returnString
Dim ModNum
Do While varNum > 0
ModNum = varNum Mod 2
varNum = varNum \ 2
returnString = Cstr(ModNum) & returnString
Loop
for i = 1 to varsit - len(returnstring)
returnString = "0" & returnString
next
TenturnTwo = returnString
End Function
Function TwoturnTen(varString) '返回参数的十进制形式
Dim SLen
Dim I
Dim returnNum
SLen = Len(varString)
For I=1 To SLen
int_power = SLen - I
returnNum = returnNum + (Cint(Mid(varString,I,1)) * (2^(int_power)))
Next
TwoturnTen = returnNum
End Function
function tobase64(str_ascii) '对输入参数进行加密,并返回加密后的字符串
dim int_array_count
dim str_rot13
str_rot13 = torot13(str_ascii)
if (len(str_rot13) mod 3 ) = 0 then
int_array_count = len(str_rot13) \ 3
else
int_array_count = (len(str_rot13) \ 3) + 1
end if
for i = 0 to int_array_count - 1
array_temp0 = mid(str_rot13 ,(i * 3 + 1) ,3) '从参数中一次取三个字符出来赋值到0变量中
for j = 1 to len(array_temp0) '此循环将0变量中的字符转换为位数为8倍数的二进制字符,并赋值到1变量
array_temp1 = array_temp1 & TenturnTwo(Asc(Mid(array_temp0 ,j ,1)) ,8)
next
for k = 1 to 24 - len(array_temp1)
'此循环将1变量的位数补满至24
array_temp1 = array_temp1 & "0"
next
for m = 0 to 3
'此循环将长度为24的变量1分割为四段,并生成一个四个字符的加密后的字符,添加至变量3末尾
array_temp2 = cint(TwoTurnTen(mid(array_temp1 ,(m * 6 + 1) ,6)))
if array_temp2>=0 and array_temp2<26 then
array_temp3 = array_temp3 & chr(array_temp2 + 97)
elseif array_temp2>25 and array_temp2<52 then
array_temp3 = array_temp3 & chr(array_temp2 + 39)
elseif array_temp2>51 and array_temp2<62 then
array_temp3 = array_temp3 & chr(array_temp2 - 4)
elseif array_temp2 = 62 then
array_temp3 = array_temp3 & "#"
elseif array_temp2 = 63 then
array_temp3 = array_temp3 & "^"
else
array_temp3 = array_temp3 & "!"
end if
next
array_temp1 = ""
next
tobase64 = array_temp3
end function
Function toAscii(str_base64) '对输入参数进行解密,并返回解密后的字符串,即用户的密码原型
dim int_array_count
int_array_count = len(trim(str_base64)) / 4
for i = 0 to int_array_count - 1
array_temp0 = mid(str_base64 ,(i * 4 + 1) ,4)
for j = 1 to len(array_temp0) '此循环将0变量中的字符转换为位数为8倍数的二进制字符,并赋值到1变量
array_temp2 = Asc(Mid(array_temp0 ,j ,1))
if array_temp2 < 123 and array_temp2 > 96 then
array_temp1 = array_temp1 & TenturnTwo((array_temp2 - 97) ,6)
elseif array_temp2 < 91 and array_temp2 > 64 then
array_temp1 = array_temp1 & TenturnTwo((array_temp2 - 39) ,6)
elseif array_temp2 < 58 and array_temp2 > 47 then
array_temp1 = array_temp1 & TenturnTwo((array_temp2 + 4) ,6)
elseif array_temp2 = 35 then
array_temp1 = array_temp1 & TenturnTwo(62 ,6)
elseif array_temp2 = 36 then
array_temp1 = array_temp1 & TenturnTwo(63 ,6)
end if
next
for k = 0 to 2
if mid(array_temp1 ,(k * 8 + 1) ,8) <> "00000000" then
array_temp3 = array_temp3 & chr(cint(TwoTurnTen(mid(array_temp1 ,(k * 8 + 1) ,8))))
end if
next
array_temp1 = ""
next
toascii = torot13(trim(array_temp3))
End Function