Sample code for 30+ languages & platforms
Node.js

Base64 Encode/Decode a String

See more Encryption Examples

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

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var bd = new chilkat.BinData();

    var 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");

    var strBase64 = bd.GetEncoded("base64");
    console.log(strBase64);

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

    var decoded = bd2.GetString("utf-8");
    console.log(decoded);

}

chilkatExample();