A block cipher is a symmetric-key encryption algorithm that operates on fixed-size groups of bits, called blocks. Rather than encrypting data one bit or byte at a time, block ciphers transform an entire block of plaintext into a block of ciphertext using a secret key. Common block ciphers include DES (64-bit blocks) and AES (128-bit blocks).
However, a block cipher alone only defines how to encrypt a single block. To encrypt data larger than one block (such as an image), we need a mode of operation. A mode of operation describes how to repeatedly apply the cipher's single-block encryption to handle arbitrary amounts of data. Different modes offer different trade-offs in terms of security, error propagation, and parallelism.
This project explores three fundamental block cipher modes of operation:
- ECB (Electronic Code Book)
- CBC (Cipher Block Chaining)
- CFB (Cipher Feedback)
Install the required Python packages:
pip install pycryptodome pillowcd src
python main.py <mode> [key] [iv]
Python main.py ECB
python main.py CBC bdec435a2958122d
python main.py CFB ea8cbfc7c4a4f1ae 0b4ebd80190e9fdc
Hint: cipher.encrypt(block)/cipher.decrypt(block) operate on a single block.