how to encode data in base64 in .net

 public string EncodeBase64(string data)
{
try
{
var s = data.Trim().Replace(” “, “+”);
if (s.Length % 4 > 0)
s = s.PadRight(s.Length + 4 – s.Length % 4, ‘=’);
return Encoding.UTF8.GetString(Convert.FromBase64String(s));
}
catch (Exception ex)
{
Log.FileLogger(ex.Message, LoggingType.Error); return null;
}
}

 

 

SHARE THIS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.