Base64 Encode And Decode In C#

Base64 Encoding

Base64 is an encoding method, where any data/images/audio file can be converted to binary data. And converted data can pass over the network without any data/image/audio loss.

Base64 Decoding

This method is revers of base64 encoding, when received at other end, through network. Decode it and process data/image/audio files for the next specific requirement

Base64 encoding in C#

var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("TestString");
Console.WriteLine(System.Convert.ToBase64String(plainTextBytes));

Base64 decoding in C#

var base64EncodedBytes = System.Convert.FromBase64String(System.Convert.ToBase64String(plainTextBytes));
Console.WriteLine(System.Text.Encoding.UTF8.GetString(base64EncodedBytes));