Base64 Encoding and Decoding using javaScript

Using btoa() and atob() functions:-

var str='123456';
var encodedString = btoa(str);
console.log('>>>>encodedString>>>>'+encodedString); //Encoded value:-MTIzNDU2

var decodedString = atob(str);
console.log('>>>>decodedString >>>>'+encodedString); //Decode value:- 123456

Leave a Reply