When I was a kid, I was into codes. I made one with the Greek alphabet and used to write myself secret notes all the time. When I had to write a five page paper in fifth grade, I wrote it on codes. So for this Stupid Python Trick, I decided to do cryptography. Not modern cryptography, but the classical cryptography that I was into as a kid. So I went through the classical cryptography section in Wikipedia and wrote Python code for just about everything there. It's got everything from ancient ciphers like Caesar and Scytale to cold war ciphers like VIC and Chao.

The code is at http://www.xenomind.com/Python/cipher.py. I wanted to play around with callable objects, so every code/cipher in the program is done as an object with a __call__ method, and an instance of each object is provided in the module. Note that the program as is will try to run a full test of every CipherFunction object. This will fail because the Book CipherFunction is expecting to have a copy of the Bible handy. There are many ways to fix this:

Modify the Book object to point to a different large text file with lots of words in it.

Comment out the Book object.

Below is the output of the full as run on my machine. It runs every cipher against a pangram I made up for the test. If there was an example on Wikipedia, it also enciphers and deciphers that, which allows me to check the enciphering in isolation. The numbers in parentheses after the test outputs are the difflib module text difference measures between the actual and expected output.