给URL地址栏中的参数加密/解密
来源:互联网 发布:ajx获取表单提交的数据 编辑:程序博客网 时间:2024/05/16 09:23
经常会看到一些网站为了安全性会对URL中的参数进行加密,也有很多朋友询问这样的问题,所以今天就贴出这么一个函数:
解密代码
使用方法:
mystring=server.URLEncode("要加密的字符串或变量")
解密代码
<%
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") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
%>
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") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
%>
使用方法:
mystring=server.URLEncode("要加密的字符串或变量")
- 给URL地址栏中的参数加密/解密
- url参数加密解密
- js加密地址栏参数并且获解密的地址栏参数
- 文件加密解密 URl参数加密解密
- js中的 地址栏的加密和解密
- URL传输参数加密解密
- javascript将url中的参数加密解密功能
- url中的参数加密
- 地址栏加密解密函数
- 获取解析URL地址栏中的参数
- JS中获取url地址栏中的参数
- 今天给大家介绍一下SpringBoot框架中URL参数如何进行Base64加密解密
- 学习URL传输参数加密解密
- URL传输参数的加密和解密
- URL参数加密解密(java版)
- URL参数加密解密(java版)
- js url参数加密 后台java解密
- JS 浏览器地址栏传递参数,参数加密/解密(编码/解码)
- [转]PHP文本数据库类设计和实现
- 太阳是否还会升起?SUN公司落末...
- javascript 日期选择(二种)
- 自动截取指定长度的字符串
- Global.asa文件使用详细介绍
- 给URL地址栏中的参数加密/解密
- 最新版Eclipse3.1及插件介绍
- 唉,这几天的问题好头痛
- [转]改进的PHP文本数据库类
- 几辈子都不用买杀毒软件了(图)-我的NOD32使用有效期
- VBScript 实现 UBB 显示代码([code][/code])附加行号, 正则实现 By Stabx
- 巧用颜色选择控件
- 最新版Eclipse3.1及插件介绍
- 不均衡信息费用的计算