3 ms·
For anyone looking for plain JavaScript base64/ascii85 codecs, I wrote a pretty decent (quicker than what I could find, concise & readable) one about a year ago
by jacobolus 16y ago
For anyone looking for plain JavaScript base64/ascii85 codecs, I wrote a pretty decent (quicker than what I could find, concise & readable) one about a year ago (would need to be modified very slightly to be a node/commonJS module, and could perhaps be a bit shorter with a different style of error handling):
http://pastie.textmate.org/pastes/695197 http://pastie.textmate.org/pastes/695197
A slight variant of this base64 codec (I believe suitable as a node/commonJS module) is also used by the http://js.io/ http://js.io/ project:
http://github.com/mcarter/js.io/blob/master/packages/std/base64.js http://github.com/mcarter/js.io/blob/master/packages/std/bas...
- pkrumins 16y agoSorry, it doesn't work on binary data: node> var buf = require('fs').readFileSync('./tests/data/data-png.png'); node> require('jacob.js').base64.encode(buf) Base64CodecError: Input contains out-of-range characters. Also node.js now has its own base64 encoding and decoding functions right in Buffer, so there is no longer need for any base64 modules.
- jacobolus 16y agoWell okay, it's intended to work in the browser (note: this was also written before Node had any decent binary data type; I haven't really been keeping track, does it now?) and so "binary data" is just a string where each byte is the lower byte of one character. It could pretty easily be modified to take advantage of better data types in contexts where they are available (or if someone's using a string for "binary data" where two bytes of data are stored in each character, modified to deal with that).
- pkrumins 16y agoNo, it still does not!