Table of Contents
A block cipher transforms a fixed-size block of data using a secret key. AES is a block cipher with a 128-bit block size and 128-, 192-, or 256-bit keys. A mode of operation defines how to use the cipher on a message, including how it handles multiple blocks and whether it checks for tampering.

What the common modes do
| Mode | How it works | What to watch for |
|---|---|---|
| ECB | Encrypts each block independently. | Equal plaintext blocks under the same key produce equal ciphertext blocks. This can expose patterns. |
| CBC | Combines each plaintext block with the previous ciphertext block. The first uses an initialization vector (IV). | Requires correct IV and padding handling. It provides no authentication by itself. |
| CFB | Feeds ciphertext back into the process to encrypt subsequent data. | Can work in segments shorter than a block. It provides no authentication by itself. |
| OFB | Feeds back the cipher’s output to produce a keystream. | Repeating the IV with the same key can repeat the keystream. |
| CTR | Encrypts successive counter values to produce a keystream. | Supports parallel processing. Counter blocks must never repeat under the same key. |
| GCM | Combines counter-mode encryption with an authentication tag. | Requires unique nonces per key and verification of the tag before using the plaintext. |

NIST documents the confidentiality modes and authenticated encryption with GCM separately. A standalone message authentication code can check integrity but does not encrypt the message.
Choose an established format and library
For a new app, use a maintained library’s authenticated encryption API or a protocol that handles it for you. An API such as AES-GCM can also authenticate unencrypted metadata, such as a message version, as associated data. Follow the library’s guidance for nonce generation, key storage, and errors. If verification fails, reject the returned data.
If you need to protect a folder rather than implement a protocol, see an example of file encryption with gocryptfs. For websites, see how to check an existing TLS configuration.
Reader Comments 0
Sign in with email or Google to join the discussion.