A simple base64 encoder. Simply pass your string and a reference to the function to get back the encoded string.
var
map ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
sample = "140bytes rocks!",
encoded = base64Encode(sample, map);
Artur Honzawa @arturhonzawa hacked the main code and further compression was done by me (@aemkei). Thanks to Rob Griffiths @bytespider and Jed Schmidt @jedschmidt for some pretty good hints!
- Proper "=" padding does not work
- IE's JScript fails with the RegExp
- Doesn't encode null bytes
Feel free to fork and improve!
See @nignag's version with correct padding: the https://gist.github.com/999166 - It is 110 bytes only!