-
-
Save anbinh/5275155 to your computer and use it in GitHub Desktop.
Base64 Encode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function base64Encode( | |
a, // string to encode | |
b, // character table ie, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" | |
c, // placeholder | |
d, // placeholder | |
e, // placeholder | |
f, // placeholder | |
g, // placeholder | |
h // placeholder | |
){ | |
h=""; | |
for(d=0; // initialise the output buffer | |
a[d]; // check if a value is returned | |
h+=b[e>>2]+b[e<<4&63|f>>4]+b[f<<2&63|g>>6||64]+b[g&63||64]) // split into 6bits characters and find it in our character table | |
for(c=4;c<7;) | |
arguments[c++]=a.charCodeAt(d++) // copy the character code into a variable declared as a placeholder | |
return h | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(a,b,c,d,e,f,g,h){h="";for(d=0;a[d];h+=b[e>>2]+b[e<<4&63|f>>4]+b[f<<2&63|g>>6||64]+b[g&63||64])for(c=4;c<7;)arguments[c++]=a.charCodeAt(d++);return h} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Base64 Encode", | |
"keywords": [ | |
"140bytes", | |
"base64", | |
"encode" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment