I know it’s ugly, but that’s because it’s Tk. I think it’s meant to be ugly. Tell the Python dudes to use GTK+ bindings for Python’s standard toolset.
It works, though, even if you can’t paste text into the textboxes.
There are two ways to run this, and both require that you have Python installed (I still use 2.5.2, but I see no reason why it shouldn’t run under 2.6).
The first, and most obvious, is to copy all of that code into a file, and then copy all of this code into a different file called
classicalcrypto.py. Put those into the same folder and just double-click on the first file to run it (if you aren’t using Windows, you’ll obviously need to
chmod +x first).
The second and slightly more complicated way is to install the classical crypto module separately. Download and untar this file, and then install it by running the setup file like
python setup.py install. Then just put this code into a file, and you won’t have to worry about keeping two files in the same folder.
If anyone has any problems getting it to work, let me know. I did try to package it using
py2exe, but, unsurprisingly,
py2exe is a piece of shit and that didn’t work.
Only most algorithms are included, because some have non-trivial key requirements; the four-square cipher, for example, requires two Polybius squares. I left the Solitaire cipher because it still works, for some reason, even though it shouldn’t. I wouldn’t trust it to be strong.
Atbash and ROT13 ignore the key you enter. Caesar and Rail Fence require it to be an integer (in Rail Fence’s case, higher than 1).
Keep in mind that Rail Fence is a permutation cipher, so trailing newlines are significant characters. For reasons I couldn’t be bothered to troubleshoot, Tk appends a newline when it updates the contents of the textbox, so if you just hit encrypt and decrypt in a row, you won’t get the original message back.