Advanced Encryption Standard (AES) is the most widely used symmetric encryption algorithm, adopted as a US federal standard in 2001. It's a block cipher that encrypts data in 128-bit blocks using keys of 128, 192, or 256 bits.
// ECB - Electronic CodeBook (AVOID)
Each block encrypted independently - reveals patterns
// CBC - Cipher Block Chaining
Blocks chained together, requires IV
Vulnerable to padding oracle if not careful
// CTR - Counter Mode
Turns block cipher into stream cipher
Parallelizable, no padding needed
// GCM - Galois/Counter Mode (RECOMMENDED)
CTR + authentication tag
Provides confidentiality AND integrity
// Python with cryptography library
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import os
key = AESGCM.generate_key(bit_length=256)
aesgcm = AESGCM(key)
nonce = os.urandom(12)
ciphertext = aesgcm.encrypt(nonce, plaintext, associated_data)
plaintext = aesgcm.decrypt(nonce, ciphertext, associated_data)