var string = "Hello folks how are you doing today?"; var encodedString = btoa(string); // Base64 encode the String var decodedString = atob(encodedString); // Base64 decode the String
> console.log(Buffer.from("Hello World").toString('base64')); SGVsbG8gV29ybGQ= > console.log(Buffer.from("SGVsbG8gV29ybGQ=", 'base64').toString('ascii')) Hello World
const encoded = window.btoa('Alireza Dezfoolian'); // encode a string const decoded = window.atob(encoded); // decode the string