How can I do Base64 encoding in Node.js?
Buffers can be used for taking a string or piece of data and doing Base64 encoding of the result. For example: > console.log(Buffer.from(“Hello World”).toString(‘base64’)); SGVsbG8gV29ybGQ= > console.log(Buffer.from(“SGVsbG8gV29ybGQ=”, ‘base64’).toString(‘ascii’)) Hello World Buffers are a global object, so no require is needed. Buffers created with strings can take an optional encoding parameter to specify what encoding the … Read more