nope, i'm not using it in a querystring.
I'm using it with my encrypted string
The enrypted string has funny characters, so that why i use with URLEncode
I dont think it helps by just reading the value of the string
Main Topics
Browse All TopicsHello Experts,
If i use the serverr.URLEncode to encrypt some strings, How could I reverse it back to original?
And in VB, do you have any similar function to reverse it back?
thanks
nguyenn
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi nguyenn,
You can use the URLDecode function.(ASP)
Try this code for VB
Public Function URLEncode(StringToEncode As String, Optional _
UsePlusRatherThanHexForSpa
Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToEncode)
Select Case Asc(Mid(StringToEncode, CurChr, 1))
Case 48 To 57, 65 To 90, 97 To 122
TempAns = TempAns & Mid(StringToEncode, CurChr, 1)
Case 32
If UsePlusRatherThanHexForSpa
TempAns = TempAns & "+"
Else
TempAns = TempAns & "%" & Hex(32)
End If
Case Else
TempAns = TempAns & "%" & _
Format(Hex(Asc(Mid(StringT
CurChr, 1))), "00")
End Select
CurChr = CurChr + 1
Loop
URLEncode = TempAns
End Function
Public Function URLDecode(StringToDecode As String) As String
Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToDecode)
Select Case Mid(StringToDecode, CurChr, 1)
Case "+"
TempAns = TempAns & " "
Case "%"
TempAns = TempAns & Chr(Val("&h" & _
Mid(StringToDecode, CurChr + 1, 2)))
CurChr = CurChr + 2
Case Else
TempAns = TempAns & Mid(StringToDecode, CurChr, 1)
End Select
CurChr = CurChr + 1
Loop
URLDecode = TempAns
End Function
' URLDecode function in Perl for reference
' both VB and Perl versions must return same
'
' sub urldecode{
' local($val)=@_;
' $val=~s/\+/ /g;
' $val=~s/%([0-9A-H]{2})/pac
' return $val;
' }
Cheers!
i found this function, but it doesnt work, it returns null value why i try to reverse it
Function URLDecode(ByVal What)
'URL decode Function
Dim Pos, pPos
'replace + To Space
What = Replace(What, "+", " ")
on error resume Next
Dim Stream: Set Stream = CreateObject("ADODB.Stream
If err = 0 Then 'URLDecode using ADODB.Stream, If possible
on error goto 0
Stream.Type = 2 'String
Stream.Open
'replace all %XX To character
Pos = InStr(1, What, "%")
pPos = 1
Do While Pos > 0
Stream.WriteText Mid(What, pPos, Pos - pPos) + _
Chr(CLng("&H" & Mid(What, Pos + 1, 2)))
pPos = Pos + 3
Pos = InStr(pPos, What, "%")
Loop
Stream.WriteText Mid(What, pPos)
'Read the text stream
Stream.Position = 0
URLDecode = Stream.ReadText
'Free resources
Stream.Close
Else 'URL decode using string concentation
on error goto 0
'UfUf, this is a little slow method.
'Do Not use it For data length over 100k
Pos = InStr(1, What, "%")
Do While Pos>0
What = Left(What, Pos-1) + _
Chr(Clng("&H" & Mid(What, Pos+1, 2))) + _
Mid(What, Pos+3)
Pos = InStr(Pos+1, What, "%")
Loop
URLDecode = What
End If
End Function
it seems working if i create a string, then encrypt using my function, then decrypt it as follow
Password before encrypt: testing
Password encrypted: x¸š4S¡
Password URLEncrypt using URLEncryp: x%B8%9A4%8DS%A1
URLEncode reverse using Unescape: x¸š4S¡
Password decrypted using Unescape: testing
but if i save my encrypted password to database, pull it out to decrypt, then it doesnt match with the original string "testing"
I tried to login using my decrypted password, and it works!
I'm lost here.
thanks
Ok, you are not using VBS, but VB. I see that you have written that before. But I probably overlooked that because this is the ASP area, not the VB area. In VB the function isn't defined apparently.
It's easy to write a quick and dirty function yourself, but not easy to make it fool-proof (but that might not be necessary).
I found some old function:
Function URLDecode(ByVal str)
Dim sOut, aStr, sLetter
sOut = Replace("" & str, "+", " ")
aStr = Split(sOut, "%")
If Ubound(aStr) > 0 Then
i = 0
sOut = aStr(i)
Do While i < Ubound(aStr)
sLetter = CHR("&H" & Left(aStr(i+1),2))
sOut = sOut & sLetter & Right(aStr(i+1),len(aStr(i
i = i + 1
Loop
End If
URLDecode = sOut
End Function
Hi all Experts,
I have found a way to encrypt and decrypt, the functions i found can work for both VB or VBScript. Believe or not, all of the functions you have provided dont work in my case, i have different result when encrypt in ASP and decrypt in Visual Basic.
Since sybe has given the most suggestions and follow up my questions, i would reward all points to him.
thanks all for your help, i really appreciated.
nguyenn
Business Accounts
Answer for Membership
by: brunobearPosted on 2004-07-01 at 12:47:33ID: 11450934
are you using this in a querystring? in which case, just reading the value of the querystring should give you the original value...