Course contentsShow
← Security
Lesson 95 of 3,0523. Symmetric Cryptography Deep DiveFree lesson

ECB Mode: Structure and Fatal Weaknesses

Learn why Electronic Codebook mode reveals patterns in plaintext and should never be used for real data.

ECB Mode: Structure and Fatal Weaknesses

You'll learn: Why Electronic Codebook (ECB) mode is considered dangerously insecure and must be avoided in practice.

What is ECB Mode?

Electronic Codebook (ECB) is the simplest block cipher mode of operation. It works by dividing your plaintext into blocks (e.g., 128-bit chunks for AES) and encrypting each block independently using the same key.

Think of it like a codebook: each unique plaintext block always maps to the same ciphertext block, just like translating words in a dictionary—the word "hello" always becomes "hola."

The Fatal Flaw: Pattern Preservation

ECB's simplicity is its downfall. Because identical plaintext blocks produce identical ciphertext blocks, patterns in your original data remain visible in the encrypted output.

Real-world example: The famous "ECB Penguin" demonstration shows what happens when you encrypt an image using ECB mode. While colors are scrambled, the penguin's outline remains clearly recognizable because areas of identical pixels (like the white background) encrypt to identical ciphertext blocks.

This means:

  • Repeated data (common in text, images, databases) leaks information
  • Attackers can detect structure without decrypting
  • Block rearrangement attacks become possible
  • Statistical analysis can reveal plaintext patterns

Why This Matters

ECB violates the fundamental goal of encryption: hiding patterns and relationships in data. Even though an attacker can't read individual blocks, seeing which blocks are identical reveals dangerous information about your data structure.

Key Takeaway: ECB mode should never be used for encrypting real data—it preserves patterns that leak critical information about plaintext, making it cryptographically weak and unsafe for any practical application.