2

I have a string converted with encryption. I would like to make this part of a URL. Is that possible if it has been converted to base64 or do I need to do something more?

var going_to_be_part_of_url = System.Convert.ToBase64String(bytOut, 0, i);

Thanks

Emily
  • 227
  • 1
  • 5
  • 9
  • 1
    In short, yes. Take a look at this link to see if this is what you are after: http://pwnedcode.wordpress.com/2008/05/12/adding-base64-strings-to-a-url-or-how-i-came-to-hate-uri-tostring/ – Neil Knight Jun 15 '11 at 15:19

2 Answers2

1

Yes, but it's not a good idea, Base64 requires that you respect the difference between upper case and lower case. URL's aren't typically case strict.

Then there's the problem of the special characters in Base64 being converted to URL encoded equivalents, making your URL's ugly and less manageable.

You should go with Base36 instead.

Neil N
  • 24,862
  • 16
  • 85
  • 145
  • 1
    There are plenty of services out there that have mixed case URLs that you have to respect. bit.ly for example which is incredibly common. If an web individual server says casing isn't important then it isn't. If it says it is, then it is. Browsers respect the case, as will all the infrastructure in between (otherwise services like bit.ly would be impossible). Whether your application does or not (IIRC, Umbraco actively doesn't) is up to that application. But the web as a whole respects case. – Colin Mackay Jun 15 '11 at 15:47
0

You can use a modified base 64 for URL Applications which is just base64 with a couple of the problem characters replaced.

The easiest way is to take your base64 string and encode perform a string replace on the problem characters when building the URL, and reversing the process when interpreting the URL.

Colin Mackay
  • 18,736
  • 7
  • 61
  • 88