ASP VBScript Base64Encode Pair of Parameters the Base64Decode

Hello,

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 -

reset.asp?I=<%=(RSPassReq.Fields.Item("ID").Value)%>&U=<%=Base64Encode(RSPassReq.Fields.Item("Username").Value)%>

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
garethtnashAsked:
Who is Participating?
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.

chaauCommented:
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
0
garethtnashAuthor Commented:
Thanks Chaau,

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

I=XX
U=YY

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?

Thanks
0
chaauCommented:
Decode the whole string and then use your own parser to read back values using the InStr and Mid functions
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

garethtnashAuthor Commented:
How ?

Any ideas?

Thanks
0
chaauCommented:
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

0

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
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.