tags:

views:

73

answers:

2

I need to Base64 encode a string, but the encoded string cannot contain "+". Wikipedia mentions a modified Base64 for URL, but I can't find a .NET class which uses this.

For my application, I can't even URL encode "+" into "%2B". This is because I pass the encoded string to a service which I have no control over, and that service mangles any strings which contain "%2B". For this reason, I want my encoded string to only contain A-Z, a-z, 0-9, -, and _.

I'm aware of this having been asked before, but I don't see a working answer. Any help would be appreciated.

+1  A: 

Use whatever base64 encoder you have, then find and replace the '+' with whatever is appropriate (whatever your other end expects instead)

Thanatos
+1  A: 

Can't you simply replace + and / by - and _ and vice versa when decoding?

Joey
Of course! I can't believe I didn't see this. That's what I get for coding late at night. Thanks.
Slack
Hm, I'm usually better late at night than early in the morning. But showing up at noon unfortunately minimizes time I could ask coworkers :-)
Joey