const initial = 'test string';
// encode
const encoded = new Buffer(initial).toString('base64');
// decode
const decoded = new Buffer(encoded, 'base64').toString('ascii');
// check
if (decoded === initial) {
console.log('Success!');
} else {
throw new Error('Encoding failed');
}
Node.js base64

Subscribe to URGN
Get the latest posts delivered right to your inbox