Skip to content

Instantly share code, notes, and snippets.

@CodyKochmann
Last active December 23, 2019 13:55
Show Gist options
  • Save CodyKochmann/2d58a1f4cec5be8de6e0 to your computer and use it in GitHub Desktop.
Save CodyKochmann/2d58a1f4cec5be8de6e0 to your computer and use it in GitHub Desktop.
small base64 object for easy encoding/decoding with b64.e() and b64.d()
class b64
constructor:()->@
e:(a)-> window.btoa unescape(encodeURIComponent(a))
d:(a)-> decodeURIComponent escape(window.atob(a))
eval:(a)-> eval decodeURIComponent(escape(window.atob(a)))
b64 = new b64
var b64=function(){
// small base64 object for easy encoding/decoding with b64.e and b64.d
// b64.eval() evaluates base64 stored javascript
// by: Cody Kochmann
this.e = function(a){return(window.btoa(unescape(encodeURIComponent(a))))};
this.d = function(a){return(decodeURIComponent(escape(window.atob(a))))};
this.eval = function(a){return(eval(decodeURIComponent(escape(window.atob(a)))))};
}
b64=new b64();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment