asp的escape和unescape(加密和解密)
|
admin
2010年7月3日 14:50
本文热度 6529
|
<%
function vbsescape(str)
dim i,s,c,a
s=""
for i=1 to len(str)
c=mid(str,i,1)
a=ascw(c)
if (a>=48 and a<=57) or (a>=65 and a<=90) or (a>=97 and a<=122) then
s = s & c
elseif instr("@*_+-./",c)>0 then
s = s & c
elseif a>0 and a<16 then
s = s & "%0" & hex(a)
elseif a>=16 and a<256 then
s = s & "%" & hex(a)
else
s = s & "%u" & hex(a)
end if
next
vbsescape = s
end function
function vbsunescape(str)
dim i,s,c
s=""
for i=1 to len(str)
c=mid(str,i,1)
if mid(str,i,2)="%u" and i<=len(str)-5 then
if isnumeric("&h" & mid(str,i+2,4)) then
s = s & chrw(cint("&h" & mid(str,i+2,4)))
i = i+5
else
s = s & c
end if
elseif c="%" and i<=len(str)-2 then
if isnumeric("&h" & mid(str,i+1,2)) then
s = s & chrw(cint("&h" & mid(str,i+1,2)))
i = i+2
else
s = s & c
end if
else
s = s & c
end if
next
vbsunescape = s
end function
%>
该文章在 2010/7/3 14:50:22 编辑过