Skip to content

Instantly share code, notes, and snippets.

@jpetazzo
Created August 4, 2014 16:48
Show Gist options
  • Save jpetazzo/f570743bb47105ec5149 to your computer and use it in GitHub Desktop.
Save jpetazzo/f570743bb47105ec5149 to your computer and use it in GitHub Desktop.
BASE27 encoding

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