There is no urldecode function in ASP, as if there is a function in aspx. I am not sure, but it is still used in asp. You can find the urldecode function written by someone else on the Internet. However, this function is incorrect and difficult to understand in some aspects. In addition, an error occurs when there are uncommon double-byte characters in the text. For example, if "bytes" is set to "% 81W" after urlencoder, decoding fails.
In fact, dual-byte encoding only requires "W" to be compiled into a hexadecimal ASC code.
Knowledge point:The cookies in the computer are also encoded by urlencode, so urldecode is also useful for cracking cookies.
The source code is as follows:
Function URLDecode (enStr)
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
You can use this method to decode "% 81W.
Of course, you can also play with a little bit to make it your own string encryption method.