471,577 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,577 software developers and data experts.

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 11090
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 XIAOLAOHU | last post: by
reply views Thread by Vinnie | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.