Convert.FromBase64String dotnet bug?

G

GeezerButler

string s = "Hello";
byte[] abc = Convert.FromBase64String(s);

This throws error
"Invalid length for a Base-64 char array."??

Does anybody have any idea about how/why this happens?
 
L

Larry Lard

GeezerButler said:
string s = "Hello";
byte[] abc = Convert.FromBase64String(s);

This throws error
"Invalid length for a Base-64 char array."??

Does anybody have any idea about how/why this happens?

Put cursor in FromBase64String. Hit F1. Help page says:
Exceptions

FormatException
The length of s, ignoring white space characters, is not zero or a
multiple of 4.
What are you actually trying to do?
 
J

Jon Skeet [C# MVP]

GeezerButler said:
string s = "Hello";
byte[] abc = Convert.FromBase64String(s);

This throws error
"Invalid length for a Base-64 char array."??

Does anybody have any idea about how/why this happens?

Yes - it's like saving a file with the word "Hello" in and then opening
it up in Paintshop Pro as if it were a JPEG: "Hello" is not a valid
Base64-encoded lump of data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top