Sunday, September 25, 2011

C#: Encode String into base64


Share at Facebook

Below is the c# code that will convert the provided string into it's corresponding base64 string. This code will first convert the string into byte array, after that it will convert the array into base64 string.


String stringData = "hello world";
Byte[] byteData = Encoding.ASCII.GetBytes(stringData);
stringData = Convert.ToBase64String(byteData);
Console.WriteLine(stringData);




No comments: