Skip to content

Instantly share code, notes, and snippets.

@ruanyl
Created December 22, 2015 19:53
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 ruanyl/124f9b5529cfc5381ddc to your computer and use it in GitHub Desktop.
Save ruanyl/124f9b5529cfc5381ddc to your computer and use it in GitHub Desktop.
base64 encoding for browser
var b64encode = function(str) {
return root.btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode('0x' + p1);
}));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment