Encoding and Decoding Base64 strings in C#

Encode a string from Base64
public static string EncodeTo64(string toEncode)
{

byte[] toEncodeAsBytes

= System.Text.Encoding.Unicode.GetBytes(toEncode);

string returnValue

= System.Convert.ToBase64String(toEncodeAsBytes);

return returnValue;

}


Decode a Base64 encoded string

public static string DecodeFrom64(string encodedData)
{

byte[] encodedDataAsBytes

= System.Convert.FromBase64String(encodedData);

string returnValue =

System.Text.Encoding.Unicode.GetString(encodedDataAsBytes);

return returnValue;

}

Comments

Popular posts from this blog

Understanding Top line and Bottom line?

How to activate PF UAN account

Scrum Master vs Product Owner