AES Encryption & Decryption Online: GCM, CBC & CTR with PBKDF2
Encrypt and decrypt with AES-GCM/CBC/CTR and PBKDF2, with byte-level and process-stage visualization.
AES-GCM, AES-CBC and AES-CTR here run through the browser's own SubtleCrypto implementation at 128, 192 or 256-bit key lengths — real, production-grade encryption, not a simplified teaching version. A hand-written XOR cipher sits alongside them specifically because it's the one mode simple enough to trace byte by byte, standing in deliberate contrast to AES's opaque, hardware-accelerated internals.
How to encrypt and decrypt text with AES
- Pick AES-GCM (selected by default, and the only mode here that detects tampering), leave Direction on Encrypt, and keep the 256-bit key length unless you must match another system.
- Supply key material: click Generate for a random raw hex key, or switch to Passphrase (PBKDF2), type a passphrase and click Generate beside the salt field. Iterations default to 200,000 with SHA-256.
- Type the plaintext and press Encrypt. The ciphertext comes out as Base64 (for GCM it already ends with the 16-byte tag), and the nonce or IV is shown separately as hex.
- Save what the output does not bundle: the Base64 ciphertext, the IV or nonce, and either the hex key or the passphrase together with its salt, iteration count, hash and key length.
- To decrypt, choose Decrypt with the same mode, re-enter that key material, paste the IV or nonce and the Base64 ciphertext, and press Decrypt.
Three real AES modes, and what SubtleCrypto will and won't show you
Encryption itself runs through crypto.subtle.encrypt/decrypt with a native CryptoKey — there is no JavaScript re-implementation of the AES round function, S-boxes or key schedule anywhere in this tool, because SubtleCrypto's implementation is both faster and more trustworthy than anything reimplemented for a browser demo. That also means the round-by-round internals are genuinely opaque; the process trace this tool shows covers key derivation, IV or nonce generation, and the encrypt/decrypt call itself, and never fabricates an internal-state visualization SubtleCrypto doesn't expose.
192-bit keys are offered but not guaranteed: the tool probes your browser at load time by attempting to import a 24-byte key, and disables the 192-bit option with an explanation if that import fails, rather than letting you configure a mode that will error out later. A fresh random IV or nonce is generated for every single operation via the browser's cryptographic random number generator — 96 bits for GCM (the size every interoperable GCM implementation expects) and a full 128-bit block for CBC's initialization vector and CTR's initial counter.
AES modes compared: GCM, CBC and CTR
All three modes run the same AES block cipher on 16-byte blocks. They differ in how consecutive blocks are tied together, whether the message has to be padded to a whole number of blocks, and whether decryption can tell that the ciphertext was changed.
- AES-GCM: 12-byte random nonce, no padding, 16-byte authentication tag appended. A wrong key, nonce or altered byte makes decryption fail outright. Use it by default.
- AES-CBC: 16-byte random IV, PKCS#7 padding up to a multiple of 16 bytes, no authentication. Mainly useful for compatibility with older systems, and only safe in real use when paired with a MAC.
- AES-CTR: 16-byte initial counter block (the tool counts in its low 64 bits), no padding, no authentication. Flipping a ciphertext bit flips the matching plaintext bit, and reusing a key with the same counter exposes both messages.
- ECB is deliberately absent. It encrypts identical 16-byte blocks to identical output, so patterns in the plaintext survive encryption, and the Web Crypto API does not offer it anyway.
Getting a key: raw hex, or a passphrase through PBKDF2
A raw key can be entered directly as hex, and it has to be exactly 16, 24 or 32 bytes — 128, 192 or 256 bits — or the tool rejects it before it ever reaches SubtleCrypto. The alternative is a passphrase run through PBKDF2, the standard password-to-key derivation function, with a configurable hash (SHA-256, SHA-384 or SHA-512) and a default of 200,000 iterations before the derived bytes are imported as an AES key — that iteration count exists specifically to make brute-forcing a weak passphrase computationally expensive, and it's shown as an explicit stage in the process trace so you can see exactly how many rounds ran.
Common AES errors and fixes
Every message below is one this tool actually shows. Most of them mean one piece of the encryption-time material is missing or slightly different.
- "Raw key must be 16, 24, or 32 bytes of hex": count the hex digits. 32, 48 or 64 are valid; spaces are ignored, but an odd digit count or a non-hex character is rejected.
- "AES-GCM needs a 12-byte nonce (hex) to decrypt", or the 16-byte IV version for CBC and CTR: paste the hex value shown when you encrypted, 24 or 32 digits long.
- "The authentication tag did not match" (GCM only): the key, passphrase, salt, iterations, hash, nonce or ciphertext differs from the encryption run, or the Base64 lost characters when copied. GCM never releases partial plaintext.
- "Provide a salt (hex) for PBKDF2": passphrase mode needs a salt. Generate one before encrypting and keep it, because decryption works only with the same salt.
- "Invalid Base64 ciphertext": the decrypt box expects the Base64 output exactly as produced, not hex and not text with stray characters.
- A generic failure in CBC or CTR mode: without a tag, a wrong key shows up as a CBC padding error or as bytes that are not valid UTF-8, which this tool refuses to print rather than displaying garbage.
- CBC output with mangled opening characters and a correct remainder: the IV is slightly off. In CBC the IV only affects the first 16-byte block.
XOR: the one mode you can watch happen
SubtleCrypto has no XOR mode, so this one is a from-scratch implementation: each byte of the message is exclusive-ORed against the corresponding byte of a repeating key, and because it's plain byte arithmetic rather than a call into opaque native crypto, every single byte of that operation can be shown — the input byte, the key byte being used (which one, in the repeating cycle), and the output byte, in both hex and binary. XOR is also its own inverse, so the identical operation encrypts and decrypts.
That transparency is also exactly what makes XOR insecure for anything real: a repeating-key XOR cipher is broken almost as easily as a Caesar shift once an attacker has any known or guessed plaintext, or when the message is longer than the key and repeats reveal the key's length. It's included here as an educational contrast to AES, not as a usable cipher.
What this tool doesn't cover
- There's no authenticated-encryption verification UI beyond what GCM itself does automatically — CBC and CTR here have no built-in integrity check at all, matching how those modes actually work; pairing either with a separate MAC is a decision left entirely to you, exactly as it would be in a real system.
- Key management, storage and rotation are out of scope entirely — this tool encrypts and decrypts a single message with a key you provide in the moment, not a system for managing secrets over time.
- GCM's authentication tag will reject tampered or corrupted ciphertext outright rather than decrypting it into garbage, but CBC and CTR have no such protection, and a corrupted CBC ciphertext block will silently produce corrupted plaintext instead of an error.
Questions people ask about Modern Symmetric Cipher Lab
- Is the AES in this tool actually secure, or is it a simplified demo version?
- It's the real thing. Encryption and decryption run through the browser's native SubtleCrypto implementation of AES-GCM, AES-CBC and AES-CTR, the same cryptographic primitive used in production software, not a simplified or weakened reimplementation. What's added on top is only a visible trace of the surrounding process — key derivation and IV generation — since AES's internal rounds are opaque by design.
- Which AES mode should I actually pick: GCM, CBC or CTR?
- GCM is generally the right default because it provides both encryption and built-in tamper detection through its authentication tag in one step. CBC and CTR encrypt but provide no integrity checking on their own — a corrupted or tampered ciphertext will decrypt into corrupted plaintext without any warning, so either would need a separate authentication step to be used safely in a real system.
- Why is the XOR cipher included next to real AES encryption?
- XOR is the one mode simple enough to show every single byte-level operation, since it's implemented directly rather than through opaque native crypto — useful for understanding what 'encryption' mechanically means at the byte level. It's also trivially breakable with any known plaintext or a message longer than its key, which is exactly the point: it demonstrates what AES protects against that a naive cipher doesn't.
- What happens if I use a passphrase instead of a raw hex key?
- The passphrase is run through PBKDF2 with a salt and, by default, 200,000 iterations of a chosen hash function to derive the actual key bytes, rather than being used directly. That iteration count is deliberately expensive to compute, which is what makes brute-forcing a guessable passphrase impractical even though the passphrase itself might be short.
- What is AES encryption?
- AES, the Advanced Encryption Standard, is the symmetric block cipher NIST standardised in 2001. It encrypts 16-byte blocks under a 128, 192 or 256-bit key. Symmetric means the same key both encrypts and decrypts, so anyone who needs to read your message has to share that key with you.
- Should I use AES-128 or AES-256?
- Both remain unbroken, and AES-128 is already far beyond brute-force reach. AES-256 adds margin, including against future quantum search, at a speed cost you will not notice for text in a browser. The tool defaults to 256 bits and greys out 192 if your browser rejects 24-byte keys.
- Why does decryption fail with an authentication error?
- In AES-GCM the tag at the end of the ciphertext is checked before any plaintext is released. One wrong key byte, a different salt or iteration count, the wrong nonce, or a single altered or missing ciphertext character fails that check, and the tool reports the error instead of showing corrupted text.
- Is client-side AES encryption safe to use?
- The cipher is the browser's native Web Crypto AES, and your text and keys stay on the page. The real risks sit around it: a short passphrase, a lost salt or IV, malware or a hostile extension on your device, or sending the key through the same channel as the ciphertext. Prefer GCM with a long random key.
Related tools on BrakeTools
- Hash Lab & Identifier — Compute and identify SHA-1/256/384/512, HMAC, and MD5 hashes, verify file checksums, and test password strength.
- RSA & Asymmetric Crypto Demo — Learn RSA with a full small-prime step table, or use real-strength RSA-OAEP encryption via your browser.
- Classical Cipher Workbench — Encrypt, decrypt, and crack classic ciphers — Caesar, Vigenère, Playfair, Morse, and more — with step-by-step visualization.
- Steganography Toolkit — Hide and extract secret messages inside PNG images using LSB embedding, with optional AES encryption.
- CSPRNG Password & Diceware Passphrase Studio — Generate CSPRNG passwords or EFF Diceware passphrases, never transmitted over the network.
Content reviewed 2026-09-27.