Symmetric Encryption Microlab

Try AES-GCM, AES-CBC, and AES-CTR with a self-contained browser AES implementation. The lab shows ciphertext, GCM authentication tags, nonce rules, and how block changes appear under each mode.

0 bytes
0 bytes
GCM usually uses a 12-byte nonce; CBC and CTR require 16-byte inputs for this lab.
Key preview
Educational view of the raw AES key. Production systems should not display or log keys.
Base64:
Choose a mode, generate a key or encrypt to auto-generate one, then decrypt with the same key and IV/nonce.

Ciphertext

Decrypted output

Decrypt uses the current mode, key, and IV/nonce. GCM also uses the tag and the exact AAD.

Block Diff Explorer

Compare two encryptions with either a controlled shared IV/nonce or realistic fresh IVs/nonces. The controlled mode isolates how plaintext changes propagate; the realistic mode shows why fresh IVs/nonces make similar messages look unrelated.

0 bytes
0 bytes

Ciphertext A blocks


      

Ciphertext B blocks


      
Legend: [same] identical block, [diff] different block. Block size is 16 bytes.

ECB-style Visualization (Unsafe)

Browsers do not expose AES-ECB through WebCrypto. This demo encrypts each 16-byte block with the lab's local AES block function and a fixed demo key. Equal plaintext blocks map to equal outputs, which illustrates ECB pattern leakage.


      
Real ECB would encrypt padded 16-byte blocks. For visualization, a short final block is zero-padded before the stand-in block encryption.

Guidance

Prefer AEAD

AES-GCM provides confidentiality and integrity in one operation. CBC and CTR only provide confidentiality unless you add a separate MAC.

Protect metadata with AAD

Use AAD for headers, routing fields, protocol versions, and other metadata that should be authenticated but not encrypted.

Never reuse CTR/GCM nonces

CTR nonce reuse repeats the keystream. GCM nonce reuse also breaks authentication and can enable forgeries.

Use random keys and careful IVs

Generate keys with a CSPRNG. CBC needs an unpredictable 16-byte IV; CTR needs a unique 16-byte counter block; GCM normally uses a unique 12-byte nonce.