Sample code for 30+ languages & platforms
C#

Base64 Encode/Decode a String

See more Encryption Examples

_LANGUAGE_ example to base-64 encode and decode a string.

Chilkat C# Downloads

C#
bool success = false;

Chilkat.BinData bd = new Chilkat.BinData();

string s = "A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump";

success = bd.AppendString(s,"utf-8");

string strBase64 = bd.GetEncoded("base64");
Debug.WriteLine(strBase64);

// To decode:
Chilkat.BinData bd2 = new Chilkat.BinData();
bd2.AppendEncoded(strBase64,"base64");

string decoded = bd2.GetString("utf-8");
Debug.WriteLine(decoded);