Solved

How do i Server.URLEncode in VB and decode in ASP?

Posted on 2004-09-23
7
242 Views
Last Modified: 2008-01-09
I'm writing a VBB app that creates the URL to direct the client. I need to URL Encode in VB and decode it the asp page. Any smart people out there know how to accomplish this? I tried a function i got from the net for VB to encode and then used unescape() in asp but strings dont match! How do i find the source code for escape() and code it in VB? This is the function that doesn't work!

Public Function URLEncode(StringToEncode As String, Optional _
   UsePlusRatherThanHexForSpace As Boolean = False) As String

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 UsePlusRatherThanHexForSpace = True Then
        TempAns = TempAns & "+"
      Else
        TempAns = TempAns & "%" & Hex(32)
      End If
   Case Else
         TempAns = TempAns & "%" & _
              Format(Hex(Asc(Mid(StringToEncode, _
              CurChr, 1))), "00")
End Select

  CurChr = CurChr + 1
Loop

URLEncode = TempAns
End Function
0
Comment
Question by:philip07
7 Comments
 
LVL 4

Expert Comment

by:avi247
ID: 12137462

1. Try these
http://www.devx.com/vb2themax/Tip/19353
http://vbnet.mvps.org/index.html?code/internet/urlescape.htm

Looks like you are using the URLEncode from this site
http://www.freevbcode.com/ShowCode.asp?ID=1512
Try using their URLDecode method to decode instead of unescape()

2. If it still does not work,
Give us an example URL thats not working for you, and your code for the string comparison.
0
 
LVL 10

Expert Comment

by:anv
ID: 12140175
0
 

Author Comment

by:philip07
ID: 12149345
OK, here we go, in VB I encrypt string "some string to encrypt" with key "mypass" using rc4 method and the encrypted result is: ±¯Ä‹¯šš¥ýb70
½h}¸ and the encoded is %B1%AF%C4%F%8B%AF%03%8D%00%00%A5%FDb70%A%BDh%7D%B8%1C%06
So i plug in the encoded string in a URL in asp and Decoded comes out as ±¯ÄF‹¯ and the DeCrypted som, str

I used the VB URLEncode and the URLDecode in asp even though i don't need to since Explored decodes it allready. The asp code Decrypts correctly but it doesn't get the full string to decrypt. What the problem is???


0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12642534
PAQed with points refunded (500)

modulo
Community Support Moderator
0
 

Author Comment

by:philip07
ID: 12687793
Sorry, but noone gave me a valid solution to this problem. I solved it myself, noone should get any points for it.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Buffer Bomb Phase Bang 9 2,422
Patching a Windows EXE 23 735
FPA Financial Planning Accelerator 4 331
how to solve the error 1935: 1 537
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now