string -> base64

  • Thread starter Thread starter Lukasz Lacki
  • Start date Start date
L

Lukasz Lacki

i want to convert string to base64 byte array. i've got problem with
it, class Convert is not very helpfull for me.

how make such converion in simplest way (input = string / output =
byte[] Base64)

...and.. some more
1) how convert string to byte[] ?
2) is there a possibility, to make a stream reading from string (like
StringReader, but it's not a stream)
3) what's going on in Convert.ToBase64String method? it's taking as
parameter byte array (i have string, question 1), and returns string
represantation of base64 (i need byte array)

thx
 
//Convert string to byte
byte[] ToByte = System.Text.Encoding.Default.GetBytes("The string");

//Convert byte to string
string ToString = System.Text.Encoding.Default.GetString(ToByte);

//Create memory stream based on byte array
MemoryStream ms = new MemoryStream(ToByte);
StreamReader sr = new StreamReader(ms);
 
Back
Top