Math curriculum developer Kirby Urner has just put the final touches on his article, Crypto Clubhouse. Inspired by Neal Stephenson's Cryptonomicon, Urner's article explores how cryptography can be used by instructors to generate interest in math and programming. It can be fun for adults as well. Return to your youth when you used your secret decoder ring to decrypt messages! All you need is a friend or two who wants to share secret messages with you! Python is a great tool for cryptography. Urner's article is a great place to start. But you don't have to stop there.
Cryptography and Python go back a long way. In 1995, Andrew M. Kuchling first announced the Python Cryptography Toolkit. PCT, later known as pyCrypt, supports common cryptographic algorithms like DES, IDEA, and MD5. In 1998 Marc-André Lemburg wanted to do some web-based cryptography, but found Kuchling's cryptography modules lacking in some key features he wanted. He decided instead to wrap Eric Young's SSL C library, SSLeay, with Python methods. The result was mxCrypto. SSLeay later became OpenSSL. MxCrypto required both OpenSSL and pyCript.
As Python and OpenSSL were updated, it became more difficult to install the two modules and get them working together. In January of this year, just before IPC 8, Kuchling merged the two into amkCrypto, making the task a bit easier. Lemburg said he would pick up development again in March, though not much has happened since the release of amkCrypto. Maybe this is because M2Crypto hit the scene in February. M2Crypto is Ng Pheng Siong's Python interface to the OpenSSL library. M2Crypto also includes support for Nightmare Software's Medusa, a high-performance http module. This makes it easy to create a simple secure https server. Zope uses Medusa for their server, ZServer. Using M2Crypto, Siong created a secure version of the Zope server, ZServerSSL. For Web-based cryptography, M2Crypto is a great tool.
If this isn't fun enough for you, there is also a Python tool for encrypting images. Frank Stajano has combined Pythonware's imaging library, PIL and a technique developed by Naor and Shamir, to create the Visual Cryptography Kit, VCK. Using VCK, you can make a transparent overlay as the key to encrypt and decrypt a an image. Without the overlay, the encrypted image is indecipherable, but combined, your message appears. While not very practical, it's a neat trick to add to your cryptography clubhouse. From beginner to advanced cryptographer, with Python as your secret decoder ring there is endless secret fun to be had.
Stephen Figgins administrates Linux servers for Sunflower Broadband, a cable company.
Read more Python News columns.
Discuss this article in the O'Reilly Network Python Forum.
Return to the Python DevCenter.
Copyright © 2009 O'Reilly Media, Inc.