Worst Encoding Scheme Ever
Andrew Polk  •  January 4, 2020  •  Python


This is the one of the worst encoding/encryption schemes you could possibly use. Do not under any circumstances use this for more than just learning python.

The Idea

This idea came to me while thinking about huffman encoding and wondering what other options there were. So I decided to create the most useless an inefficient encoding scheme i could think to create.

The Encoder

The encoder starts by taking some input text to encode, it then padds the input so that the length is a multiple of three. That string is then converted into a list of numbers (0-127), ASCII encoding.

Once the input has been prepared it is then sent to the encoder 3 numbers at a time. Three was chosen because any longer and the output takes too long to process. Encoding is simple (but not efficient), a random number generator returns values until one is found that matches the first number to be encoded. If the 2nd and 3rd numbers also match the next two values a match has been found. The encoding function then returns the number of times it asked for a random number as an output. If the match was not found the first time, this process is repeated until one is found.


The Decoder

The encoder starts by taking a comma delimited string of numbers. These numbers represent the number of times a random number must be generated in order to find the correct sequence of letters (in ASCII).



This encoding scheme can take over a minute to encode a simple sentence. The sentence, "The Quick Brown Fox Jumps Over The Lazy Dog" takes 58 seconds to encode.

Extra 'improvements' could further increase the runtime such as changing the block size from 3 to 4. Changing the block size to be the length of the input text could result in the program never finishing unless you happen to get extremely lucky

The current code sets the random seed to '0', this can be changed to any number or changed to an input.

© 2019 Andrew Polk