How to

convert bytes to base-64 string and vice versa

Published: 2. November 2011 | Updated: 2. November 2011
License: Microsoft Public License (MS-PL)
Categories: Converting
Tags: C# Conversion Text
Was this snippet helpful for you? YESYES / NONO
string base64 = Convert.ToBase64String(new byte[] {104, 101, 108, 108, 111});

Console.WriteLine(base64);

byte[] bytes = Convert.FromBase64String(base64);

foreach (byte b in bytes)
{
    Console.WriteLine(b);
}
Console Output:
aGVsbG8=

104
101
108
108
111
Send us feedback about this snippet »



Related Snippets: