欢迎来到天地奔腾博客交流
经常会看到一些网站为了安全性会对URL中的参数进行加密,加密后的URL还原函数代码:

<%
Function URLDecode(enStr) 'URL解码函數 
dim deStr 
dim c,i,v 
deStr="" 
for i=1 to len(enStr) 
c=Mid(enStr,i,1) 
if c="%" then 
v=eval("&h"+Mid(enStr,i+1,2)) 
if v<128 then 
deStr=deStr&chr(v) 
i=i+2 
else 
if isvalidhex(mid(enstr,i,3)) then 
if isvalidhex(mid(enstr,i+3,3)) then 
v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2)) 
deStr=deStr&chr(v) 
i=i+5 
else 
v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1))))) 
deStr=deStr&chr(v) 
i=i+3 
end if 
else 
destr=destr&c 
end if 
end if 
else 
if c="+" then 
deStr=deStr&" " 
else 
deStr=deStr&c 
end if 
end if 
next 
URLDecode=deStr 
end function 

function isvalidhex(str) 
isvalidhex=true 
str=ucase(str) 
if len(str)<>3 then isvalidhex=false:exit function 
if left(str,1)<>"%" then isvalidhex=false:exit function 
c=mid(str,2,1) 
if not (((c>="0"wink.gif and (c<="9"wink.gif) or ((c>="A"wink.gif and (c<="Z"wink.gif)) then isvalidhex=false:exit function 
c=mid(str,3,1) 
if not (((c>="0"wink.gif and (c<="9"wink.gif) or ((c>="A"wink.gif and (c<="Z"wink.gif)) then isvalidhex=false:exit function 
end function 
%>
Trackback URL for this entry

GB2312http://www.whssni.com/blog/trackback.php?id=56&encode=gb2312

UTF-8 http://www.whssni.com/blog/trackback.php?id=56&encode=utf-8

公司简介 | 友情链接 | 网站地图 | 人才招聘 | 帮助中心 | 留言反馈 | 联系我们
武汉企业网站 域名注册 虚拟主机 武汉企业建站 网站建设方案 网站推广 企业邮局 企业信箱 搜索排名 网站模板 企业建站成功案例
武汉天地奔腾网络信息技术有限公司
电话:027-87660809 传真:027-87660809
地址:武汉市街道口珞珈山大厦B-1203室 邮编:430079
版权所有《中华人民共和国增值电信业务经营许可证》:鄂 B2-20040084
Copyright@2004-2005 WHSSNI CO.,LTD 网站备案号:鄂 B2-20040084