Home > Articles > Programming > Python

Python Libraries

  • Print
  • + Share This

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://www.amk.ca/python/code/amk-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)
  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.