views:

173

answers:

1

Getting a few different exceptions related to Base-64 strings in C#. Below are the exceptions along with sample string. I don't know too much about this topic but I believe I did confirm the lengths of the following strings are multiples of 4. I'm hoping these issues are all related but I'm not sure. Any help is appreciated.

"Invalid character in a Base-64 string." DcxWhbe30oLrUI69U41gSnm7eU2c8qOx7k/eKnSaG3ZDlv8BIPHJKxl0DStVUtsjdxufrZd30K4IAl0XxBIKgKUlOt4k+nVPrfCnM4HHzw19GHnYlTr2DLhw6iD0goEnMk+bJG2xWQ4wRLLn8KOj6DdBxTes6sdpoeWKxcAHPZ2FFXqC3MfQ+SMMV7re9YiY9ZpudFFr1QVRMztzinK5YA==

"Length of the data to decrypt is invalid." jq6xC0Dv+oeL0MXOei7wNIQgD+aon+S8N2ZfDyAO+5dlm/lIBYN+aCn2Xjnyi/XCzv7Liag5aaKXZ3b+7P7+R7lmarsT9ugnFrnvjInsvUxsbk4EAjIP55O9d7XXYnARW3yjW7klLyR0U9JjMVsISKThDtLe4rOJHgDvYahF454YOn5GlVXBoB+qNnLscGZ6

"Invalid length for a Base-64 char array." C8MutyUPoTrmmnprFV3wqxMMVs7O5J4NA61jhZLaCSbwteklqGHFuuSlhf0mH8L5FLJ+jcrWuns2zz+Q/o5tA0DCDGnEAxDxKraR8Ip/iDUrTCS9ZAW0VrZpqUY4EPhyCbSpdU0OwfQ05eHXqwU6LIzz3gqavpi6AlMP9H5GYTaxsfQEByswjizWs5hO2ZmH

+1  A: 

As I went to look at what I was using to decode the string in response to Andrey's question, I realized that I had been making an assumption that was blinding me from the real issue.

The data string is being passed through a querystring parameter and I was assuming that parameter as seen in the custom error message I was getting was the bad string when, in fact, a little debugging showed that the string I was actually attempting to decode had whitespaces. Posting the string through the querystring was causing all the plus (+) signs to get decoded into whitespace. I am able to resolve this issue from there.

Thank you to anyone who spent time reading this rather misguided question.

Greg
Also note that ViewState data is Base64 encoded, and occasionally a buggy browser (old versions of Safari?) would truncate ViewState and cause the exceptions to show up sometimes.
David Crowell