Parameter encryption/decryption in the URL address bar

Source: Internet
Author: User
Server. urlencode (STR)
Decryption code
<%
Function urldecode (enstr) 'url decoding function
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> = "") and (C <= "Z") Then isvalidhex = false: Exit Function
C = mid (STR, 3,1)
If not (C> = "0") and (C <= "9") or (C> = "") and (C <= "Z") Then isvalidhex = false: Exit Function
End Function
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.