← Cryptography guide

K032 / Cipher modes and AEAD

ECB mode

ECB electronic codebook mode weakness · Survey date 2026-12-05

ECB is the simplest block cipher mode and encrypts plaintext blocks independently.

CRYPTOGRAPHY LAB / K032

Cryptography Lab · ECB mode

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Legacy / non-secure

AES-ECB (raw, no padding)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Reference ↗

Open lab →

Definition and overview
ECB is the simplest block cipher mode and encrypts plaintext blocks independently. Source document ↗
Classification and reversibility
Reversible block cipher mode mapping plaintext blocks to ciphertext blocks. Source document ↗
Key or secret requirements
Requires a secret random symmetric key K shared by communicating parties. Source document ↗
Operating principle and structure
Split plaintext into fixed-size blocks, encrypt each independently with same key, no IV. Source document ↗
Key size, block size and parameters
AES-ECB uses 16-byte blocks and 128/192/256-bit keys. Source document ↗
Security strength and recommendation
Defined in SP 800-38A but generally not recommended due to inherent weakness, including NIST's 2023 announcement. Source document ↗
Known attacks and vulnerabilities
Pattern leakage makes it vulnerable to known- and chosen-plaintext attacks. Source document ↗
Standards and certification
NIST SP 800-38A defines five confidentiality modes including ECB. Source document ↗
Typical uses
Consider only for unupgradable legacy systems or when a standard requires ECB. Source document ↗
Implementations, libraries and tools
Crypto++ uses an ECB_Mode<AES> object with SetKey. Source document ↗
Decryption or decoding
Decrypt each ciphertext block independently with the same key. Source document ↗
Advantages
Simple and fast, particularly advantageous on multicore systems. Source document ↗
Limitations and cautions
Not semantically secure; exposes inter-block correlations and should be avoided. Source document ↗
Distinguishing encryption, encoding and hashing
ECB is an encryption mode using a block cipher, not encoding or hashing. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Split plaintext into 16-byte AES blocks and encrypt independently; identical plaintext blocks yield identical ciphertext. Decrypt each block and remove padding.

Procedure

Pad plaintext to block multiple, split, encrypt independently with same key and concatenate. Decrypt by splitting ciphertext, independently decrypting and removing padding. Encoding/decoding is separate keyless format conversion.

Scenario

For legacy devices supporting only ECB, minimize data scope and add integrity protection. Replace with AES-GCM/AEAD in new designs; restrict ECB to mandated standards or interoperability tests.

Pitfalls and alternatives

ECB is deterministic, leaks patterns and provides no integrity authentication. Use an authenticated construction or AEAD such as GCM, not ECB except for legacy compatibility.

References