---
{
  "title": "ECB and block-cipher modes",
  "summary": "A cipher needs a construction suited to the data and protection goal.",
  "topic": "foundations",
  "level": "Intermediate",
  "updated": "2026-10-12",
  "units": [
    6
  ],
  "aliases": [],
  "sources": [
    {
      "title": "NIST: Cryptographic Standards and Guidelines",
      "url": "https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines"
    }
  ],
  "published": "2026-10-02",
  "editorialVersion": 2
}
---

## The idea

Electronic Codebook mode encrypts each block independently under the same key, causing equal plaintext blocks to produce equal ciphertext blocks. This can reveal patterns, making it unsuitable for many message-encryption tasks. Other modes and authenticated-encryption constructions have their own parameter and integrity requirements. Choose a maintained, appropriate high-level API rather than selecting a mode by familiarity. Learning historical behavior is different from recommending it for a product.

## In practice

Repeated blocks in a structured file retain recognizable equality patterns under ECB even though the blocks are encrypted.

## A common misunderstanding

Encryption does not automatically hide every relationship in the input or detect tampering.

## Check your understanding

Why prefer an appropriate authenticated-encryption construction?

**Think it through:** It can provide confidentiality and integrity together when keys, nonces, and validation are handled correctly.

## Equal blocks preserve a visible relationship

Imagine a fictional form containing many repeated fixed-width fields. Under ECB with one key, equal plaintext blocks produce equal ciphertext blocks. The reader may not recover the words directly, but can observe equality and repetition. Encryption has concealed block values while leaving a relationship that can be meaningful in structured data.

This is why evaluating confidentiality requires a stated goal. If a system should hide whether two fields contain the same value, deterministic independent block processing does not satisfy that goal. Adding a longer AES key does not change ECB's equality behavior. The mode, not merely the block cipher, determines this property.

Other constructions address different needs but introduce their own requirements. Authenticated encryption can protect confidentiality and detect unauthorized modification when used correctly. Its nonce rules, associated-data handling, and verification behavior must be followed; switching a label from ECB to another mode without reviewing those details is not a complete repair.

## Demonstrate equality using synthetic blocks

Create a paper message with several repeated blocks labelled A, B, and A. Draw ECB's independent transformation as A becoming one ciphertext label each time and B becoming another. The exercise demonstrates the leak without using a real secret or relying on a recognizable image.

Then describe what an application actually needs to hide and whether it must detect tampering. Use those requirements to choose a maintained high-level API rather than implementing a custom combination of primitives. Historical examples are valuable because they expose why a security property matters. They should be clearly separated from current product recommendations, so learners do not mistake an easy-to-demonstrate mode for a suitable default encryption design.

## Keep exploring

- [[aes]]
- [[symmetric-encryption]]
- [[legacy-cryptography]]
