Convert a string to bytes
Here is my code that I have a problem:
Code:
InputText = "sklfjlkjd";
byte [] EncryptedData = Convert.FromBase64String (InputText) // Error on line: Invalid length for a Base-64 char array.
There is no white in my string so I do not understand too well the error.
Any idea?
Re: Convert a string to bytes
Is it toBase64 that you want to do?
Probably you made a mistake in writing the code.
Re: Convert a string to bytes
Your string is not a multiple of 4 (in length). If the string contains base64, it should be padded with "=" at the end if it is not multiple of 4
I also wonder if this is not the opposite that you want to do ...
Re: Convert a string to bytes
Why don't you use something like System.Text.ASCIIEncoding.ASCII.GetBytes(s) ?
Re: Convert a string to bytes
Convert.FromBase64String Method
Converts the specified String, which encodes binary data as base 64 digits, to an equivalent 8-bit unsigned integer array.
For more information, look here: http://msdn.microsoft.com/en-us/libr...e64string.aspx