Sunday, April 5, 2015

Base64 encode/decode with Javascript

P
Javascript supports you to base64 encode and decode with sample APIs. Now, let see what it can do

function myFunction() {
    var str = "www.it-4shared.com";
    var enc = window.btoa(str);
    var dec = window.atob(enc);
}

output should be

d3d3Lml0LTRzaGFyZWQuY29t
www.it-4shared.com

NOTE: atob() method is supported in IE10 and later

Sample




No comments:

Post a Comment