0

Please help take a look at the below base64 string. It doesn't seem to have an invalid character but still throws an error when converting from base64.

Apologies for the possible duplicate question but the answer didn't solve my issue.

Decode base64 string C#

Base64

DEeTJc6PZ0v2z8X+/gIPH2qgIMTFjjWwDTZQ69qtKE4yI6UOiJ5PQQRqWClvG+eMJc0YtID5Di/2KyV9Tw9OyFR2vj8z1WW4bu7QPp33zmSfsiGQzcJkyDWJ6zWK2gPM2wi3EFbCfQLU+mTkyg10yQscrT7k0pO2BfuTK1mKwyg=

Error

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

Code used

string data = Convert.ToBase64String(byteArray);
byte[] byte = Convert.FromBase64String(data);

Thanks in advance.

Great Efue
  • 90
  • 5
  • I can't reproduce the error with the sample you've included, although it definitely doesn't seem to be a useful string. – David L Jan 16 '23 at 21:42
  • @DavidL I am trying to convert byte array to base64 and convert the base64 back to byte array. In the process of converting from base64 to byte array, I get the error. – Great Efue Jan 16 '23 at 21:53
  • It might be good if you can provide the source byte array as well as the string that you are producing, so that others can attempt to reproduce the behavior. As I mentioned, I can't reproduce your error, which indicates that what you've posted in your question isn't the same as what you are seeing in your code. – David L Jan 16 '23 at 21:54

0 Answers0