Convert.ToBase64String C# code example

Example 1: how do i convert to base64 c#

public static string Base64Decode(string base64EncodedData) {
  var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
  return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}

Example 2: how do i convert to base64 c#

public static string Base64Encode(string plainText) {
  var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
  return System.Convert.ToBase64String(plainTextBytes);
}

Example 3: convert array byte to string 64

byte[] temp_backToBytes = Convert.FromBase64String(temp_inBase64);