This project is a Python simulation of AES-128 encryption using Object-Oriented Programming (OOP) and standard data structures.
It demonstrates the core AES operations:
- SubBytes: Non-linear byte substitution using the S-Box
- ShiftRows: Row-wise cyclic shifts for diffusion
- MixColumns: Column mixing (diffusion using GF(2^8))
- AddRoundKey: XOR with the round key for confusion
The code works on 16-byte blocks and uses a 16-byte key (AES-128).
- Converts plaintext into a 4×4 state matrix
- Performs AES rounds with SubBytes, ShiftRows, MixColumns, and AddRoundKey
- Converts the encrypted state back into a hexadecimal ciphertext
- Easily extendable for full AES implementation (key expansion and MixColumns)
from aes import AES
key = "2b7e151628aed2a6abf7158809cf4f3c" # 16-byte AES-128 key
plaintext = "3243f6a8885a308d313198a2e0370734" # 16-byte plaintext
aes = AES(key)
ciphertext = aes.encrypt_block(plaintext)
print("Ciphertext:", ciphertext)