ASP VBScript Base64Encode Pair of Parameters the Base64Decode


I have a pair of parameters 'I=XX&U=ZZ'

I want to encrypt these and I'm using Base64Encode to do so as seen here

However currently, by VBScript looks like this -


Open in new window

I would rather Base64 encode both parameters, so no 'I=XX&U=YY' instead just '.asp?XrtytdfdRgJJoIBFSestg' etc

So really there are two questions here,

Firstly how do I Base64 encode the entire query string

Secondly, how do I Base64 the whole query string using this parasites each parameter into a variable that can be used in a recordset or stored procedure?

Appreciate your thoughts and input.

Thank you
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

To encode the whole string use this code:
reset.asp?<%=Base64Encode("I=" & RSPassReq.Fields.Item("ID").Value & "&U=" & RSPassReq.Fields.Item("Username").Value)%>

Open in new window

I did not understand your second question
garethtnashAuthor Commented:
Thanks Chaau,

How do I read the parameters back into vbscript variables, so I can get


instead of XCFDGRYTvbvtytVBFHT

In other words i want the query string completely base64 encoded, but i want to be able to use the parameters on the receiving page..

Any thoughts?

Decode the whole string and then use your own parser to read back values using the InStr and Mid functions
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

garethtnashAuthor Commented:
How ?

Any ideas?

Use the Base64Decode to decode your string, and then just some basic InStr manipulation:
decodedString = Base64Decode("XCFDGRYTvbvtytVBFHT")
I = GetSubstring("I=")
U = GetSubstring("U=")
Function GetSubstring(what)
GetSubstring = ""
pos = InStr(decodedString, what) 
var I, U
If pos > 0 Then
   pos1 = InStr(pos, decodedString, "&") 
   If pos1 < 1 Then pos1 = Len(decodedString)+1
   GetSubstring = Mid(decodedString, pos+Len(what), pos1 - pos - Len(what))
End If
End Function

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garethtnashAuthor Commented:
Superb - thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.