开发者

Can a string encoded with Base64 not contain "+"?

I need to Base64 encode a string, but the encoded string cannot contain "+". Wikipedia mentions a modified Bas开发者_StackOverflow社区e64 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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜