buffer.from() js base64 code example
Example 1: base64 encode node js
> console.log(Buffer.from("Hello World").toString('base64'));
SGVsbG8gV29ybGQ=
> console.log(Buffer.from("SGVsbG8gV29ybGQ=", 'base64').toString('ascii'))
Hello World
Example 2: buffer from base64
const b64string = /* whatever */;
const buf = Buffer.from(b64string, 'base64');