convert string to base64 js code example
Example 1: nodejs string to base64
> console.log(Buffer.from("Hello World").toString('base64'));
SGVsbG8gV29ybGQ=
> console.log(Buffer.from("SGVsbG8gV29ybGQ=", 'base64').toString('ascii'))
Hello World
Example 2: javascript encode base64
const encoded = window.btoa('Alireza Dezfoolian');
const decoded = window.atob(encoded);
Example 3: base 64 in js
var string = 'Hello World!';
var encodedString = btoa(string);
console.log(encodedString);
var decodedString = atob(encodedString);
console.log(decodedString);
Example 4: javascript base64 decode
var decodedString = atob(encodedString);