Skip to content

Instantly share code, notes, and snippets.

@arbo-hacker
Last active January 22, 2016 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arbo-hacker/3b1d17bd888a8dd890c7 to your computer and use it in GitHub Desktop.
Save arbo-hacker/3b1d17bd888a8dd890c7 to your computer and use it in GitHub Desktop.
Encode and Decode string in Javascript
// Decode a base-64 encoded string:
var quote = "Stay hungry. Stay foolish.";
var encode = window.btoa(quote);
var decode = window.atob(encode);
console.log("Encoded String: " + enc + "<br>" + "Decoded String: " + dec);
// The result will be:
// Encoded String: U3RheSBodW5ncnkuIFN0YXkgZm9vbGlzaC4=
// Decoded String: Stay hungry. Stay foolish.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment