Skip to content

Instantly share code, notes, and snippets.

@aemkei
Forked from 140bytes/LICENSE.txt
Created May 24, 2011 08:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aemkei/988339 to your computer and use it in GitHub Desktop.
Save aemkei/988339 to your computer and use it in GitHub Desktop.
140byt.es - Base64 Encoder / Decoder
/*
* Base64 encoder and decoder
*
* Works in all modern Browsers (Chrome, Firefox, Safari, Opera).
* Does not work in IE.
*
* More info: https://developer.mozilla.org/en/DOM/window.btoa
*/
// Creates a base-64 encoded ASCII string from a string of binary data.
function base64Encode(ascii_string){
return btoa(ascii_string);
}
// Decodes a string of data which has been encoded using base-64 encoding.
function base64Decode(encoded_string){
return atob(encoded_string);
}
var base64Encode=btoa,base64Decode=atob;
function base64Encode(b){return btoa(b)}
function base64Decode(a){return atob(a)}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "base64",
"description": "Base64 encoder and decoder",
"keywords": [
"encode",
"decode",
"base64"
]
}
@jed
Copy link

jed commented Jul 11, 2011

hey @aemkei, would you mind taking the comments out of this package.json?

@aemkei
Copy link
Author

aemkei commented Jul 11, 2011

@jed Okay, just removed them.

@Downchuck
Copy link

These work with DOMString, not binary data. Running raw binary data can result in the browser throwing an error.

@mgttt
Copy link

mgttt commented Jan 8, 2019

u must be joking, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment