Binary to text encoding – state of the art and missed opportunities
notes.volution.ro
notes.volution.ro
Literally every user of git uses these schemes routinely. Hashes and UUIDs (and friends like ULID) are binary data and almost always presented textually.
> There are however still a few cases where they are the proper tool
Notably missing: allowing user input of binary data, and passing binary data through text-only channels (e.g. JSON does not support raw binary data, so b2t is necessary to send binary data through any JSON-based channel).
> see the section about efficiency above; although this isn't strictly related to binary to text encoding, none of the current tools offer the option to transparently compress / decompress on encoding / decoding
Because compression is completely orthogonal, and there’s many situations where you’re better off leaving it out e.g. compress, b2t, put it into JSON, and send that with DEFLATE transfer-encoding. The first compression is largely wasted, you’d almost certainly be better off only compressing the JSON.
And obviously if you put a compression step after the b2t encoding why did you b2t encode in the first place?
I agree. This was my thought throughout the article. Most of the features he wanted like checksumming and compression would be better provided on other layers. I think the reason that base64 is so popular is that it does one thing well. You can always add checksumming, but it often isn't needed.
Interesting!
> They are analogous in purpose to the NATO phonetic alphabet used by pilots, except a longer list of words is used, each word corresponding to one of the 256 distinct numeric byte values.
https://en.wikipedia.org/wiki/PGP_word_list
I have a project like this that I created once, but using a different set of words.
https://github.com/ctsrc/Base256
I'm gonna go ahead and replace the word list there with the PGP word list actually! :D (It's still pre-1.0, so breaking changes like this are fine.)
from wikipedia https://en.wikipedia.org/wiki/YEnc
> yEnc is a binary-to-text encoding scheme for transferring binary files in messages on Usenet or via e-mail. It reduces the overhead over previous US-ASCII-based encoding methods by using an 8-bit encoding method. yEnc's overhead is often (if each byte value appears approximately with the same frequency on average) as little as 1–2%, compared to 33–40% overhead for 6-bit encoding methods like uuencode and Base64.
The last part is critical - yEnc is incompatible with more complex encodings like UTF-8, which is why it is completely useless today.
A cursory check revealed that Xenix had uuencode and uudecode! So I uuencoded the disk images on the host system, pasted them into the emulator with its ability to type out entire files at the virtual keyboard, then uudecoded them in the Xenix guest and used Xenix to blit them onto fresh floppy images. Done! I had install disks.
I'm sure that Alaithea Moondreemur, the striped-socks-wearing pink-haired unicorn fox, and hir headmates will be along by and by to tell us that uuencode/uudecode are obsolete, insecure, and should not be included in modern distros because, news flash, it's not the 80s anymore and modern applications use 8-bit-clean binary protocols anyway. But this opportunity to get my 2023 Linux to talk to the first Unix I ever used... man, it was a trip!
It's binary because the UTF-8 standard states how each Unicode code-point (i.e. character) is to be translated into a series of bytes.
But, because each (correct) UTF-8 byte sequence can be translated back into a Unicode code-point sequence, you can see it as text also. :)
(BTW, from my knowledge, UTF-8 doesn't specify a canonical encoding of Unicode text, thus for cryptographic purposes, especially signatures, perhaps one should treat it with care.)
Part of why it's a good idea to normalize input before password hashing, as an example... It will likely become more common over time to use emoji as passphrase input.