469,312 Members | 2,472 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

Convert.FromBase64String dotnet bug?

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?

Jan 24 '07 #1
3 11004
Becase s is not a base64-encoded string.

Try Convert.ToBase64... instead.
"GeezerButler" <ku******@gmail.comwrote in message
news:11**********************@13g2000cwe.googlegro ups.com...
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?

Jan 24 '07 #2
GeezerButler wrote:
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?

--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Jan 25 '07 #3
GeezerButler <ku******@gmail.comwrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 25 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Swarup | last post: by
4 posts views Thread by Dan | last post: by
7 posts views Thread by Shankar | last post: by
6 posts views Thread by Bob Altman | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.