Cryptographic Mode Visualizer

See why ECB mode leaks image patterns and CBC does not. Interactive side-by-side view of block cipher modes, plus an ECB, CBC, CTR and GCM comparison.

Advertisement

See Why ECB Mode Is Broken — With Your Own Eyes

This visualizer encrypts a test image twice, side by side: once with a scheme that behaves like ECB and once with a scheme that behaves like CBC. The ECB result still shows the picture. The CBC result is noise. Nothing about the key is weaker in the first case — the difference is purely the mode of operation, and this is the single clearest demonstration in cryptography that a strong cipher used the wrong way provides almost no confidentiality at all.

The tool is educational. It is built for students, security engineers explaining a finding to a developer, and anyone who has read “never use ECB” and wants to understand why rather than take it on faith. It uses simplified per-pixel transforms that reproduce the structural behaviour of each mode; it is not an AES implementation and is not intended for encrypting real data.

What You Can Do

  • Choose a source image — the classic penguin, a smooth gradient, a text sample, or a checkerboard. Each exposes the flaw differently: large flat regions show it most dramatically, and the checkerboard shows how a repeating pattern survives encryption intact.
  • Change the key with a slider and watch both outputs update. The ECB image changes colour but keeps its shape, no matter which key you pick.
  • Change the initialization vector and watch the asymmetry: the CBC image scrambles completely, while the ECB image does not move at all — because ECB has no concept of an IV.
  • Read the comparison table covering six modes: ECB, CBC, CFB, OFB, CTR and GCM, with their parallelism, error propagation behaviour, whether they hide patterns, and typical use.

How to Use It

  1. Start with the penguin. It is the canonical example for good reason — the outline stays perfectly legible under ECB.
  2. Move the key slider. Notice that the ECB image recolours but never stops being a penguin. A different key does not fix a broken mode.
  3. Move the IV slider. The CBC panel changes entirely; the ECB panel is unchanged. This is the tool’s central lesson in one interaction.
  4. Try the checkerboard. Identical input blocks produce identical output blocks under ECB, so the pattern passes straight through.
  5. Read the mode table to see where each mode fits and why GCM is what modern protocols actually use.

The ECB Penguin, Explained

The image that made this problem famous is Tux, the Linux penguin, encrypted in ECB mode. Anyone seeing the result immediately understands the flaw without knowing any cryptography: the ciphertext is unmistakably still a penguin, in psychedelic colours. It has been used in textbooks and talks for decades because it needs no explanation.

The mechanism is simple. A block cipher such as AES transforms a fixed-size block — 16 bytes for AES — into another block of the same size. Electronic Codebook (ECB) mode splits the plaintext into blocks and encrypts each one independently with the same key. That makes it deterministic: the same plaintext block always produces the same ciphertext block. An image is full of repetition — a white background is thousands of identical blocks — so every one of those becomes the same ciphertext block, and the structure of the image survives encryption perfectly.

This is not a picture-specific problem. Any structured data leaks the same way. Encrypt a database column of country codes with ECB and the ciphertext still tells you which rows share a country. Encrypt a fixed-format record with ECB and an attacker can identify, count and reorder records without ever recovering the key.

How CBC Fixes It

Cipher Block Chaining (CBC) makes each block depend on everything before it. Before encrypting a block, it XORs the plaintext block with the previous block’s ciphertext. The first block has no predecessor, so it is XORed with a random initialization vector instead:

C₁ = Eₖ(P₁ ⊕ IV)
Cₖ = Eₖ(Pₖ ⊕ Cₖ₋₁) for every subsequent block

Two consequences follow. First, identical plaintext blocks no longer produce identical ciphertext, because each is XORed with a different preceding ciphertext block — so patterns disappear and the penguin becomes noise. Second, encrypting the same message twice with the same key but a different IV yields completely different ciphertext, which is why the IV slider transforms the CBC panel and leaves the ECB panel untouched.

The IV must be unpredictable and must never be reused with the same key, but it is not a secret — it is normally transmitted or stored alongside the ciphertext in the clear. A fixed or predictable IV reintroduces exactly the leakage CBC exists to prevent.

CBC has costs. Encryption is inherently sequential, since each block needs the previous ciphertext, so it cannot be parallelised (decryption can be). A single corrupted ciphertext block damages two plaintext blocks on decryption. And crucially, CBC provides confidentiality only — it does nothing to detect tampering, which is the root of a long history of padding-oracle attacks against systems that decrypted CBC data without authenticating it first.

The Six Modes at a Glance

ModeFull nameParallelisableError propagationHides patternsTypical use
ECBElectronic CodebookEncrypt & decryptSingle block onlyNoNever use for data
CBCCipher Block ChainingDecrypt onlyTwo blocksYesDisk encryption, legacy TLS
CFBCipher FeedbackDecrypt onlyTwo blocks plus bitsYesStream-like encryption
OFBOutput FeedbackNeitherSingle bitYesSatellite links, noisy channels
CTRCounterEncrypt & decryptSingle blockYesHigh-performance, AES-NI
GCMGalois/Counter ModeEncrypt & decryptSingle block plus auth failureYesTLS 1.3, IPsec — recommended

The practical answer for new work is GCM, or another authenticated mode such as ChaCha20-Poly1305. Authenticated encryption gives you confidentiality and integrity in one operation: modified ciphertext fails authentication and is rejected rather than decrypting into plausible-looking garbage. That closes the entire class of attacks that plagued unauthenticated CBC deployments. CTR mode is fast and parallel but, like CBC, is unauthenticated on its own — GCM is essentially CTR with an authentication tag bolted on properly.

One warning that applies to CTR and GCM: the counter or nonce must never repeat under the same key. Nonce reuse in GCM is catastrophic — it leaks the XOR of the two plaintexts and can expose the authentication key itself.

What This Tool Is Not

The visualizer uses simplified per-pixel operations chosen to reproduce each mode’s structural behaviour visibly and instantly in a browser. It is a teaching model, not AES, and the outputs are not cryptographically secure. Use it to understand and to explain; use a vetted library for anything real.

Related Tools

To work with actual encryption, try the AES encryption tool. For the asymmetric half of the picture, see public key concepts explained visually and the RSA playground. To see which modes real servers negotiate, look up a suite in the cipher suite reference.

Frequently Asked Questions

Why is ECB mode insecure?

Because it is deterministic. Identical plaintext blocks encrypt to identical ciphertext blocks under the same key, so any repetition or structure in the data survives encryption. With images the leak is visible; with structured records it is just as real but less obvious.

What is the ECB penguin?

An image of Tux the Linux penguin encrypted in ECB mode, in which the penguin remains clearly recognisable. It is the standard illustration that a strong cipher in the wrong mode provides very little confidentiality.

What does the initialization vector do?

In CBC it is XORed with the first plaintext block so that encrypting the same message twice with the same key yields different ciphertext. It must be unpredictable and never reused with a given key, but it does not need to be secret. ECB ignores it entirely, which is exactly what the IV slider demonstrates.

Which mode should I actually use?

GCM, or another authenticated encryption mode such as ChaCha20-Poly1305. They provide integrity as well as confidentiality, so tampered ciphertext is rejected rather than silently decrypted.

Is CBC still acceptable?

It is not broken as a confidentiality primitive, and it remains common in disk encryption and legacy protocols. But it offers no integrity protection, and systems that decrypt CBC data without first authenticating it have a long history of padding-oracle vulnerabilities. Prefer an authenticated mode for new designs.

Does this tool use real AES?

No. It applies simplified per-pixel transforms that reproduce the structural behaviour of ECB and CBC so the difference is visible immediately. It is a teaching model, not a cryptographic implementation.

Can I encrypt my own image with it?

The tool ships four built-in test images chosen to expose the flaw clearly. That is the point of the exercise — large flat areas and repeated patterns are exactly what ECB fails to hide.

Does anything I do here get uploaded?

No. The visualization is generated in your browser on a canvas. Nothing is transmitted.

What Is a Cryptographic Mode of Operation

A cryptographic mode of operation defines how a block cipher (like AES) processes data larger than a single block. Since AES encrypts exactly 128 bits at a time, a mode of operation specifies how to handle messages of arbitrary length — how blocks relate to each other, whether encryption can be parallelized, and whether the mode provides authentication in addition to confidentiality.

Choosing the right mode is as important as choosing the right cipher. A strong cipher like AES can be rendered insecure by a poorly chosen mode, and the wrong mode can introduce vulnerabilities even when the underlying algorithm is sound.

How Block Cipher Modes Work

All modes take a block cipher, a key, and (usually) an initialization vector (IV) or nonce as inputs. They differ in how they chain blocks together:

ModeFull NameTypeParallel EncryptParallel DecryptAuthentication
ECBElectronic CodebookBlockYesYesNo
CBCCipher Block ChainingBlockNoYesNo
CTRCounterStreamYesYesNo
GCMGalois/Counter ModeStreamYesYesYes (AEAD)
CCMCounter with CBC-MACStreamNoNoYes (AEAD)
CFBCipher FeedbackStreamNoYesNo
OFBOutput FeedbackStreamNoNoNo

AEAD (Authenticated Encryption with Associated Data) modes like GCM and CCM provide both confidentiality and integrity in a single operation, eliminating the need for a separate HMAC.

Visual Differences Between Modes

This tool visualizes how each mode processes plaintext blocks. The key differences to observe:

  • ECB encrypts each block independently — identical plaintext blocks produce identical ciphertext blocks, visibly leaking patterns (the famous "ECB penguin" demonstration)
  • CBC chains each block to the previous ciphertext block via XOR, so identical plaintext blocks produce different ciphertext — but encryption cannot be parallelized
  • CTR converts AES into a stream cipher by encrypting sequential counter values and XORing with plaintext — fully parallelizable in both directions
  • GCM extends CTR with a Galois field multiplication step that authenticates both the ciphertext and any additional unencrypted data (like packet headers)

Common Use Cases

  • Learning cryptography: Visualize why ECB mode leaks information and why CBC/CTR/GCM modes do not
  • Security architecture decisions: Choose the right mode based on performance requirements, parallelization needs, and whether authentication is required
  • Code review: Verify that application code uses appropriate modes — flag ECB usage as a critical vulnerability
  • Compliance documentation: Explain to auditors why your implementation uses GCM over CBC and reference NIST SP 800-38D

Best Practices

  1. Default to AES-GCM — For most applications, GCM provides the best combination of performance, parallelism, and built-in authentication.
  2. Never use ECB for structured data — ECB is only safe for encrypting single blocks (like individual keys). For any multi-block data, it leaks patterns.
  3. Never reuse nonces in GCM — GCM nonce reuse is catastrophic: it reveals the authentication key and enables plaintext recovery. Use a counter or random 96-bit nonce with collision probability tracking.
  4. Use CTR+HMAC if GCM is unavailable — Encrypt-then-MAC using CTR mode and HMAC-SHA256 provides equivalent security to GCM when AEAD is not available in your library.
  5. Understand IV requirements — CBC requires unpredictable IVs (use CSPRNG). CTR/GCM require unique nonces (counters are fine). Mixing these requirements causes vulnerabilities.

Frequently Asked Questions

Why is ECB mode insecure?+

ECB (Electronic Codebook) encrypts each block independently with the same key. Identical plaintext blocks produce identical ciphertext blocks, revealing patterns in the original data. The classic "ECB penguin" demonstration shows that an encrypted image in ECB mode still reveals the shape of the original image.

How does CBC mode solve the ECB problem?+

CBC (Cipher Block Chaining) XORs each plaintext block with the previous ciphertext block before encryption. This means identical plaintext blocks produce different ciphertext blocks, hiding patterns. An Initialization Vector (IV) is used for the first block. Changing the IV produces completely different ciphertext for the same plaintext.

What is the difference between block cipher modes?+

ECB encrypts blocks independently (insecure). CBC chains blocks together. CFB converts a block cipher into a stream cipher. OFB generates a keystream independent of plaintext. CTR uses a counter for parallelizable encryption. GCM adds authentication to CTR mode for authenticated encryption. Each has different performance and security tradeoffs.

Which block cipher mode should I use?+

For most applications, use GCM (Galois/Counter Mode) as it provides both confidentiality and authentication with good performance. Use CBC when GCM is not available. Never use ECB for anything beyond single-block encryption. CTR is good for parallelized encryption. This is covered in CISSP Domain 3.

What is an Initialization Vector (IV)?+

An IV is a random or unique value used with the encryption key to ensure that the same plaintext encrypts to different ciphertext each time. IVs must be unpredictable (CBC) or unique (CTR/GCM) but do not need to be secret. Reusing IVs with the same key can compromise security, especially in CTR and GCM modes.

Related tools

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.