asp的escape和unescape(加密和解密)
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
[p]<%[br]function vbsescape(str) [br] dim i,s,c,a [br] s="" [br] for i=1 to len(str) [br] c=mid(str,i,1) [br] a=ascw(c) [br] if (a>=48 and a<=57) or (a>=65 and a<=90) or (a>=97 and a<=122) then [br] s = s & c [br] elseif instr("@*_+-./",c)>0 then [br] s = s & c [br] elseif a>0 and a<16 then [br] s = s & "%0" & hex(a) [br] elseif a>=16 and a<256 then [br] s = s & "%" & hex(a) [br] else [br] s = s & "%u" & hex(a) [br] end if [br] next [br] vbsescape = s [br]end function[/p]
[p]function vbsunescape(str) [br] dim i,s,c [br] s="" [br] for i=1 to len(str) [br] c=mid(str,i,1) [br] if mid(str,i,2)="%u" and i<=len(str)-5 then [br] if isnumeric("&h" & mid(str,i+2,4)) then [br] s = s & chrw(cint("&h" & mid(str,i+2,4))) [br] i = i+5 [br] else [br] s = s & c [br] end if [br] elseif c="%" and i<=len(str)-2 then [br] if isnumeric("&h" & mid(str,i+1,2)) then [br] s = s & chrw(cint("&h" & mid(str,i+1,2))) [br] i = i+2 [br] else [br] s = s & c [br] end if [br] else [br] s = s & c [br] end if [br] next [br] vbsunescape = s [br]end function [br]%>[/p] 该文章在 2010/7/3 14:50:22 编辑过 |
关键字查询
相关文章
正在查询... |