Thursday, 4 February 2016

How to make Base64 Encryption and Decryption Using javascript atob() & btoa() method in client side ?

     
  <!DOCTYPE html>
<html>
<body>

<p>Click the button to decode a base-64 encoded string.</p>

<button onclick="myFunction()">Test</button>

<p> The atob() method is not supported in IE9 and earlier.</p>

<p id="str"></p>

<script>
function myFunction() {
    var str = "http://plateofcode.blogspot.in/";
    var enc = window.btoa(str);
    var dec = window.atob(enc);

    var res = "Encoded String: " + enc + "<br>" + "Decoded String: " + dec;
    document.getElementById("str").innerHTML = res;
}
</script>

</body>
</html>


 
It will show as....




Click the button to decode a base-64 encoded string.





Note: The atob() is not supported in IE9 and earlier.





No comments:

Post a Comment