~bohwaz/blog/

Avec de vrais morceaux de 2.0 !

PHP 5 implementation of Bubble Babble encoder / decoder

Do you know Base64? This is a binary encoding that is widely used to store and transmit binary data using simple ASCII characters. Bubble Babble is also binary data encoding, much like Base64, but it alternates consonants and vowels to encode data as pseudo-words that can be easily pronounced.

Take for example the "1234567890" string. It will be encoded as "MTIzNDU2Nzg5MA==" with Base64, and as "xesef-disof-gytuf-katof-movif-baxux" with Bubble Babble. Doesn't the second string looks like a bit more readable?

Bubble Babble (see also the spec) also includes two features to check for string integrity which are nowhere to be found in Base64. The first one is begin and end markers. See the "x" characters at begin and end of the encoded string? These marks the begin and end of a string. The second feature is an integrated checksum to detect transmission errors.

The advantages of Bubble Babble:

  • readable string
  • pronounceable text
  • begin and end markers
  • checksum to detect transmission errors

The main disadvantage is the size of the encoded string, which is 3 times bigger than the original string, whereas Base64 is only 1.37 times bigger.

I think that this might be really useful to exchange gpg fingerprints for example, as hexadecimal isn't really pleasant to pronounce. But there might be a lot of other use-cases I haven't thought of.

There is implementations of Bubble Babble in Perl, Go, Python, Javascript, etc. But in PHP there was only a old script. And of all those implementations, only the Go one was implementing the decoding. So I wrote my own implementation for PHP, using objects and exceptions, and put it under the GNU LGPL license, as always.

This implementation can be found here : bubble_babble.php

Hope that might be useful to someone :)

Write a comment
(optional)
(optional)
(mandatory)
                 _        _ _                     
  ___ ___  _ __ | |_ _ __(_) |__  _   _  ___ _ __ 
 / __/ _ \| '_ \| __| '__| | '_ \| | | |/ _ \ '__|
| (_| (_) | | | | |_| |  | | |_) | |_| |  __/ |   
 \___\___/|_| |_|\__|_|  |_|_.__/ \__,_|\___|_|   
                                                  
(mandatory)

URLs will create links automatically.
Allowed HTML tags: <blockquote> <cite> <pre> <code> <var> <strong> <em> <del> <ins> <kbd> <samp> <abbr>