

The easiest way to install it is using pip, a Python package manager. Nonetheless, ECB is very interesting for an illustrative point of view due to its simplicity, which is why we are analyzing it in this tutorial.Īs mentioned, we will use the pycrypto library to encrypt and decrypt the data with AES. You can check here a very illustrative example of the security problems that may arise from using ECB mode.Įven for single block messages, if we repeat the same message over time, then an attacker can understand which messages are identical. In terms of security, ECB is generally a bad choice since identical plain text blocks are encrypted to identical cipher text blocks, which allows a possible attacker to disclose patterns in our ciphered messages. In our case, we are going to use ECB (Electronic Code Book), which uses the same unaltered key to encrypt each block of plain text. Since we may want to encrypt data larger than 128 bits, we need to choose a block mode.

The algorithm can use keys of 128, 192 and 256 bits and operates on data blocks of 128 bits (16 bytes). In this tutorial we will check how to encrypt and decrypt data with AES-128 in ECB mode, using Python and the pycrypto library.ĪES stands for Advanced Encryption Standard and it is a cryptographic symmetric cipher algorithm that can be used to both encrypt and decrypt information.
