AES

From emboxit
Jump to: navigation, search

<cpp> The currently available block ciphers are listed in the following table, and are in the Crypto.Cipher package: Cipher Key Size/Block Size AES 16, 24, or 32 bytes/16 bytes ARC2 Variable/8 bytes Blowfish Variable/8 bytes CAST Variable/8 bytes DES 8 bytes/8 bytes DES3 (Triple DES) 16 bytes/8 bytes IDEA 16 bytes/8 bytes RC5 Variable/8 bytes </cpp>

<python> In this article I want to present how to use PyCrypto for simple symmetric encryption and decryption of files using the AES algorithm.

from Crypto.Cipher import AES

key = '0123456789abcdef' mode = AES.MODE_CBC encryptor = AES.new(key, mode)

text = 'j' * 64 + 'i' * 128 ciphertext = encryptor.encrypt(text) </python> from the README <python> An example usage of an encryption algorithm (AES, in this case) is:

>>> 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' </python>


<cpp> 2 . Byte Oriented AES (Low Resource Version)

Released: 22nd November 2006 Updated 29th August 2008: To add a version that does not use tables

This is a slower version of AES that is capable of operating on systems where only byte operations are available. It does however offer some opportunities for speed improvements if 32-bit operations are supported. This version uses only limited processor resources and should hence be capable of use on small embedded processor systems. In addition to providing normal pre-keyed AES operation, this version provides AES subroutines with 'on the fly' keying for 128 and 256 bit keys and can hence remove the need for memory to hold the full AES key schedule. </cpp>