C#

Base64 Encoding and Decoding in C#

Encoding string to Base64 format:

public String Encode2Base64(String text)
{
	try
	{
		return Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(text));
	}
	catch (Exception)
	{
		return null;
	}
}

Decoding string from Base64 format:

public String DecodefromBase64(String text)
{
	try
	{
		return Encoding.ASCII.GetString(Convert.FromBase64String(text));
	}
	catch (Exception)
	{
		return null;
	}
}