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!
did any of you guys try using
.replace? seems like you could use one function that "toggles" from first binary replacement and then string building.