tags:

views:

156

answers:

3

I need to pass 2 parameters in a query string but would like them to appear as a single parameter to the user. At a low level, how can I concatinate these two values and then later separate them? Both values are Base64 encoded.

?Name=abcyxz

where both abc and xyz are separate Base64 encoded strings.

+1  A: 

You should either use some separator or store the length of the first item.

Mehrdad Afshari
Can you give me an example of a valid separator that doesn't need to be encoded (a valid character in a query string that isn't found in a Base64 encoded string.)Thanks,
Andrew Robinson
Why don't you just encode the separator with the data, and split it after you've decoded it?
John Rasch
I think a dot (.) would do.
Mehrdad Afshari
+4  A: 

why don't you just do something like this

temp = base64_encode("var1=abc&var2=yxz")

and then call

?Name=temp

Later you can decode the whole string and split the vars. (sry for pseudo code :P)

Edit: a small quote from wikipedia

The current version of PEM (specified in RFC 1421) uses a 64-character alphabet consisting of upper- and lower-case Roman alphabet characters (A–Z, a–z), the numerals (0–9), and the "+" and "/" symbols. The "=" symbol is also used as a special suffix code. The original specification, RFC 989, additionally used the "*" symbol to delimit encoded but unencrypted data within the output stream.

Alekc
The disadvantage of this approach is that the source data is more restricted (it cannot be a generic byte[], you should care about separators).
Mehrdad Afshari
A: 

First of all, I would be curious as to why you can't just pass two parameters. But with that as a given, just choose any character that's a valid character in a URL query string, but won't show up in your base64 encoding, such as ~

Clyde