AES-GCM is an AEAD mode that provides both confidentiality and integrity with a single API. It outputs an authentication tag and supports associated data (AAD) to bind headers. CBC, by contrast, requires padding and must be combined with a MAC (e.g.,HMAC-SHA256) in an encrypt-then-MAC construction to resist tampering.
Implementation pitfalls with CBC include padding oracles, IV reuse, and MAC-then-encrypt ordering errors. If you must use CBC for compatibility, use random IVs, constant-time checks, and authenticated encryption via a separate MAC. Otherwise, prefer AES-GCM.
Operational guidance: never reuse nonces/IVs with the same key, store or transmit the nonce alongside ciphertext, and rotate keys periodically.
Try: AES-GCM, AES, HMAC-SHA256