Most IP addresses I run into are IPv4 addresses that look like
127.0.0.1. They’re short and fairly easy to remember, but there are only 2^32 or about 4.3 billion of them, and that’s not nearly enough to go around any more.
There’s a new IP protocol called IPv6 that has 2^128 possible addresses. That’s about three hundred trillion trillion trillion addresses, and even if you only count the ones that are valid to use that’s still trillions of trillions of addresses for every person on Earth.
Which is great, but IPv6 addresses are long and ugly and hard to remember, like
29A1:A600:F19B:B703:7080:5387:3685:A2AF. Why not encode them in a prettier way?
Check out your current IP as a haiku, or try encoding and decoding below.
Mainly for fun. 99% for fun. But IP addresses, particularly IPv6 addresses, are difficult to commit to memory or communicate to someone else. To read out a full IPv6 address takes 32 words (39 if you include the separator characters). An IPv6 hipku is just 17 one-syllable words. (But seriously, it’s really just for fun.)
Get the code
Hipku is available on Github under an MIT license.
How to run
hipku.js from the
dist folder. You can also grab hipku via npm with npm install hipku and use it with
var Hipku = require('hipku'). Call
Hipku.encode() to encode an IPv4 (period-separated) or IPv6 (colon-separated) address as a haiku and
Hipku.decode() to decode a hipku to an IP address.
How it works
An IPv6 address is composed of 8 hextets with 65536 (2^16) possible values for each hextet, creating a total address space of 65536^8, which is the same as 2^128.
A hipku has 16 slots for one-syllable words with 256 possible words for each slot, creating an address space of 256^16, which is the same as 2^128.
Put another away, by having 256 possible choices for each word and choosing 16 words, there are the same number of possible combinations as there are IPv6 addresseses, so we can uniquely identify each IPv6 address with one 16 word combination. Hipku goes one extra step and stores those 16 words in a format that reads as a haiku.
Hipku stores each octet
n of an IP address as two numbers:
y = n % m and
x = (n - y) / m. For IPv4 addresses
m = 16 and for IPv6 addresses
m = 256.
y are stored as positions in a series of dictionaries, where the length of each dictionary is equal to
The hipku is formed from the series of encoded words laid out according to a key and schema that produces human-readable sentences.
For example, to encode
67d1:8f17:b5a9:dbee:89d4:42a6:7154:4f69 as a hipku:
First convert from hex to decimal:
Convert each section to a factor of 256 and a remainder:
[103, 209]:[143, 23]:[181, 169]:[219, 238]:[137, 212]:[66, 166]:[113, 84]:[79, 105]
For each number in each section, get the appropriate dictionary from the key and get the word at that position from the dictionary.
[last, sprouts]:[plain, boys]:[pelt, rushed]:[suave, torn]:[pale, stiff]:[dreams, ripe]:[heads, drip]:[good, grooms]
Use the schema to format the hipku, using filler words where necessary.
Last sprouts and plain boys pelt rushed suave torn pale stiff dreams. Ripe heads drip good grooms.
In the same way that IPv6 addresses are usually expressed in hexidecimal, a base-16 numbering system, hipku for IPv6 can be thought of as a base-256 numbering system where each digit is represented by a single word rather than a single character.
Hipku is an idea that’s been swirling about at the back of my mind for about six months. I was playing around with procedurally generated text for another project and became curious about how much information I could encode in a series of word choices.
It’s been done before – for example, video host Gfycat uses a randomly generated adjective-adjective-animal scheme to create links for hosted files, rather the usual choice of a randomly generated string of characters. This creates links that look like gfycat.com/YellowHelplessDikdik rather than imgur.com/nyNjOEN — but I wanted to create something of my own.
I did some back-of-the-envelope math, testing different inputs and different sizes of dictionaries, to see if it were possible to represent complex text in fewer characters than the input format. At first I planned to create a general-purpose library that would accept arbitrary text as an input and return a human-readable series of sentences that was however long as was necessary as an output. But taking an input of unspecified length and returning an output of unspecified length didn’t seem very satisfying or useful — a bit like playing tennis with the net down.
Constraints are what make writing fun. I can’t remember which came first, choosing haiku as the output format or choosing IPv6 addresses as the input, but combining both ideas immediately seemed like a natural and elegant pairing – to the extent that I would search every now and then to stamp out the niggling suspicion that someone must already have created such a system.
The most challenging part of the project turned out to be creating lists of 256 single-syllable adjectives, nouns and verbs. (In order to fit within the 17-syllable constraint of a haiku, it was essential to use monosyllabic words – using two-syllable words would require a dictionaries with 65536 entries to encode the same information in the same space.) To meet the 256-word target, I had to include some obscure or awkward entries and as a result hipkus are not yet as elegant or memorable as I hope them to be in the future.
Encoding IPv4 addresses is a very different matter. The address space is so sublimely small that I only needed dictionaries with 16 entries to fill 8 word slots (16^8 is equal to 256^4), so I took some liberties with multi-syllable or even multi-word dictionary entries to create haiku that are more readable and pleasing to the eye and ear.