Reputation: 142
I have a string which I need to convert to base64. The default convert
byte[] cipherbytes = rsa.Encrypt(plainbytes, false);
return Convert.ToBase64String(cipherbytes);
I get a string which has '+' like "pURT+TFG=" and is converted to a space when sent as a get, so I can't compare to the original.
Upvotes: 3
Views: 1057
Reputation: 156978
First, it sounds as a bad idea to send large sets of bytes in the query string. Short byte arrays should be fine. Make sure if this is what you need.
Second, you have to URL encode your base64 encoded string, by calling HttpUtility.UrlEncode
or WebUtility.UrlEncode
(prefer the latter):
byte[] cipherbytes = rsa.Encrypt(plainbytes, false);
return WebUtility.UrlEncode(Convert.ToBase64String(cipherbytes));
Upvotes: 5