AES
The Advanced Encryption Standard is a common symmetric encryption standard with a few different modes of operation
Python
pip install pycryptodomefrom Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import os
# ECB Encrypt
plaintext = b"Hello, world! (ECB)"
KEY = os.urandom(16) # 16 bytes
cipher = AES.new(KEY, AES.MODE_ECB)
ciphertext = cipher.encrypt(pad(plaintext, AES.block_size))
# ECB Decrypt
cipher = AES.new(KEY, AES.MODE_ECB)
plaintext = unpad(cipher.decrypt(ciphertext), AES.block_size)
print(plaintext) # b'Hello, world! (ECB)'
# CBC Encrypt
plaintext = b"Hello, world! (CBC)"
KEY = os.urandom(16) # 16 bytes
IV = os.urandom(16) # 16 bytes
cipher = AES.new(KEY, AES.MODE_CBC, IV)
ciphertext = cipher.encrypt(pad(plaintext, AES.block_size))
# CBC Decrypt
cipher = AES.new(KEY, AES.MODE_CBC, IV)
plaintext = unpad(cipher.decrypt(ciphertext), AES.block_size)
print(plaintext) # b'Hello, world! (CBC)'ECB Mode

Decrypt suffix (data after plaintext)
CBC Mode

Bit-flipping Attack

Padding Oracle
CTR Mode
Known Plaintext Attack
Repeated Key Attack
CFB Mode

Predictable Output
GCM Mode
Last updated

