Skip to content

Instantly share code, notes, and snippets.

@navopw
Last active September 10, 2016 23:02
Show Gist options
  • Save navopw/afc4bf8bf43a9f2bfdd8b036f6a31977 to your computer and use it in GitHub Desktop.
Save navopw/afc4bf8bf43a9f2bfdd8b036f6a31977 to your computer and use it in GitHub Desktop.
Javascript Base64 encode & decode
function BASE64_encode(str) {
return window.btoa(unescape(encodeURIComponent(str)));
}
function BASE64_decode(str) {
return decodeURIComponent(escape(window.atob(str.replace(/\s/g, ''))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment