asp 编码解码函数

来源:互联网 发布:2013网络十大神曲 编辑:程序博客网 时间:2024/05/18 06:09
<%
function encode(soStr)
 
for i=1 to len(soStr)         
  TempNum
=hex(asc(mid(soStr,i,1)))  
  
if len(TempNum)=4 then
   encode
=encode & "%"& left(cstr(TempNum),2& "%"& right(cstr(TempNum),2)
  
else
   
Randomize
   encode
=encode &"%"& chr(72+int(rnd*18))& chr(72+int(rnd*18)) & "%" & cstr(TempNum)
  
end if
 
next
end function

function decode(x)
 x
=replace(x,"%","")               
 
for i=1 to len(x) 
  
if asc(mid(x,i,1))>=72 then
   x
=replace(x,mid(x,i,1),"0")
  
end if
 
next
 
for i=1 to len(x) step 4
  decode
=decode& chr(int("&H" & mid(x,i,4))) 
 
next
end function
%
>

 
原创粉丝点击