Skip to content

Instantly share code, notes, and snippets.

@soulshake
Forked from jpetazzo/README.md
Created August 8, 2014 00:08
Show Gist options
  • Save soulshake/eba79707e7f77c1751ee to your computer and use it in GitHub Desktop.
Save soulshake/eba79707e7f77c1751ee to your computer and use it in GitHub Desktop.

Base 27 encoding

This is just for lulz.

  • Take a character string (ASCII8, no character >242).
  • Transform each byte into a sequence of 5 trinary digits (i.e. from 00000 to 22222).
  • Concatenate all trinary digits (i.e. a long sequence of 0, 1, and 2).
  • Add extra 0s at the end so that the total length is divisible by 3.
  • Break down by groups of 3.
  • Transform each group of 3 into an integer, ranging from 0 to 26.
  • Map 0 to -, and 1 to 26 to A to Z.
  • Concatenate the result.

Example:

encode('Hello, world!')
'HAFV-LAJAQCPLVCLSICSCR'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment