Download:
wget http://www.amk.ca/files/python/crypto/pycrypto-2.0.1.tar.gz
Decompress:
gunzip pycrypto-2.0.1.tar.gz tar -xf pycrypto-2.0.1.tar
Installation:
cd pycrypto-2.0.1 python setup.py install
Some good examples are in README file.
In Python:
Import module:
from Crypto.Cipher import AES
>>> obj=AES.new('This is a key456', AES.MODE_ECB)
>>> message="The answer is no"
>>> ciphertext=obj.encrypt(message)
>>> ciphertext
'o\x1aq_{P+\xd0\x07\xce\x89\xd1=M\x989'
>>> obj2 = AES.new('This is a key456', AES.MODE_ECB)
>>> obj2.decrypt(ciphertext)
'The answer is no'
Cypher inicialization:
password = 'This is a key456' cipher = AES.new(password, AES.MODE_ECB)
Encryption:
plaintext = "The answer is no" ciphertext = cipher.encrypt(plaintext)
>>> ciphertext
'o\x1aq_{P+\xd0\x07\xce\x89\xd1=M\x989'
Decryption:
password = 'This is a key456' cipher2 = AES.new(password, AES.MODE_ECB) plaintext = cipher2.decrypt(ciphertext)
>>> plaintext 'This is a key456'
Enjoy …
…matus…