< BACKMake Note | BookmarkCONTINUE >
152015024128143245168232148039199167010047123209178152124239215162147036037064089094099064

Cryptographic

The following modules implement various algorithms of cryptographic nature.

For more information about this topic, you can also check out the following Web site:

http://starship.python.net/crew/amk/python/crypto.html

It contains cryptographic modules written by Andrew Kuchling for reading and decrypting PGP files.

md5

The md5 module is a cryptographically secure hashing algorithm that implements an interface to RSA's MD5 message digest algorithm. Based on a given string, it calculates a 128-bit message signature.

sha

The sha module is a message digest algorithm that implements an interface to NIST's secure hash algorithm, known as sha. This module takes a sequence of input text and generates a 160-bit hash value.

mpz

The mpz module implements the interface to part of the GNU multiple precision integer libraries.

rotor

The rotor module implements a permutation-based encryption and decryption engine. (The design is derived from the Enigma device, a machine used by the Germans to encrypt messages during WWII.)

						
>>> import rotor
>>> message = raw_input("Enter the message")
>>> key = raw_input("Enter the key")
>>> newr = rotor.newrotor(key)
>>> enc = newr.encrypt(message)
>>> print "The encoded message is: ", repr(enc)
>>> dec = newr.decrypt(enc)
>>> print "The decoded message is: ", repr(dec)

					


Last updated on 1/30/2002
Python Developer's Handbook, © 2002 Sams Publishing

< BACKMake Note | BookmarkCONTINUE >

Index terms contained in this section

devices
      Enigma
Enigma device

© 2002, O'Reilly & Associates, Inc.