string -> base64

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
 
B

Bill

//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);
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top