Cryptographic Mode Visualizer
Visualize the difference between ECB and CBC encryption modes with pixel-level demonstrations using the Canvas API. Upload images or use built-in test patterns to see why ECB mode leaks information. Compare ECB, CBC, CFB, OFB, CTR, and GCM modes.
Want to learn more?
Visualize how different block cipher modes of operation (ECB, CBC, CTR) affect encryption security.
Read the guideChoosing the Right Encryption Mode?
Our DevSecOps team ensures your applications use proper encryption modes and implementations.
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:
| Mode | Full Name | Type | Parallel Encrypt | Parallel Decrypt | Authentication |
|---|---|---|---|---|---|
| ECB | Electronic Codebook | Block | Yes | Yes | No |
| CBC | Cipher Block Chaining | Block | No | Yes | No |
| CTR | Counter | Stream | Yes | Yes | No |
| GCM | Galois/Counter Mode | Stream | Yes | Yes | Yes (AEAD) |
| CCM | Counter with CBC-MAC | Stream | No | No | Yes (AEAD) |
| CFB | Cipher Feedback | Stream | No | Yes | No |
| OFB | Output Feedback | Stream | No | No | No |
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
- Default to AES-GCM — For most applications, GCM provides the best combination of performance, parallelism, and built-in authentication.
- 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.
- 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.
- 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.
- 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
Common questions about the Cryptographic Mode Visualizer
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.
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.
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.
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.
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.
Explore More Tools
Continue with these related tools
ℹ️ Disclaimer
This tool is provided for informational and educational purposes only. All processing happens entirely 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. Use at your own discretion.