1
I have a Base64 string but the C# compiler says it is not valid, I get the following error:
The entry is not a valid Base 64 character string, as it contains a non-base 64 character, more than two fill characters, or an illegal character between the fill characters.
My code is this:
String s_data = "RmluYWwtUmVjaXBpZW50OiByZmM4MjI7IGd1YXJhbmFicmFzaWxAZ3VhcmFuYXN0b2NrLmNvbQ0KQWN0aW9uOiBmYWlsZWQNClN0YXR1czogNS4wLjANCkRpYWdub3N0aWMtQ29kZTogc210cDsgVGhlIGVtYWlsIGFjY291bnQgdGhhdCB5b3UgdHJpZWQgdG8gcmVhY2ggZG9lcyBub3QgZXhpc3QuIFBsZWFzZSB0cnkgZG91YmxlLWNoZWNraW5nIHRoZSByZWNpcGllbnQncyBlbWFpbCBhZGRyZXNzIGZvciB0eXBvcyBvciB1bm5lY2Vzc2FyeSBzcGFjZXMuIExlYXJuIG1vcmUgYXQgaHR0cHM6Ly9zdXBwb3J0Lmdvb2dsZS5jb20vbWFpbC8_cD1Ob1N1Y2hVc2VyIG40c29yMzk2MDY5M3dtaC4zNCAtIGdzbXRwDQpMYXN0LUF0dGVtcHQtRGF0ZTogV2VkLCAwNyBNYXIgMjAxOCAwOTo1MToxNiAtMDgwMCAoUFNUKQ0K";
byte[] data = Convert.FromBase64String(s_data);
string decodedString = Encoding.UTF8.GetString(data);
I tested the string
of data
on that website and there converts normally. I have converted other strings
in base64
but this is giving problem.
Thanks, I realized that I made this change when I was going to encode, but I didn’t when I was going to decode. It worked obg
– Leonardo Bonetti