AES modes
Encrypt and decrypt with AES in CBC, CTR, ECB, CFB, OFB, CCM, PCBC, IGE and XTS modes, with PKCS#7 or other padding, in your browser.
About this tool
AES is a block cipher: on its own it encrypts exactly 16 bytes. A mode of operation turns it into something that can encrypt a whole message, and the mode decides how blocks are chained, whether padding is needed and what the IV does.
Pick a mode, enter a key and IV in hex, and encrypt text, hex or Base64. Paste a ciphertext to decrypt it. CBC, ECB, PCBC and IGE pad the message to whole blocks, with PKCS#7 by default; CTR, CFB and OFB need no padding. CCM adds an authentication tag, as RFC 3610 defines, and XTS is the mode used for disk encryption.
Questions
- Why does my AES-CBC decryption fail or give garbage?
- Usually the key, IV or padding differs from what was used to encrypt. Check that the key is the right length in bytes (not characters), that the IV is the one sent with the message, and that both sides use the same padding, most often PKCS#7. Also make sure the ciphertext is decoded from the right format, hex or Base64.
- Which AES mode should I use?
- For new designs, an authenticated mode: AES-GCM (on the Encrypt and decrypt tool) or CCM. Use CBC, CTR and the others to work with existing systems. Avoid ECB, which leaks patterns in the data.
- What is PKCS#7 padding?
- It fills the last block with N bytes of value N, so a message that needs 3 more bytes ends in 03 03 03. A message that is already a whole number of blocks gets a full extra block of sixteen 0x10 bytes, so the padding can always be removed without ambiguity.
- Is my input sent to a server?
- No. The page loads a compiled Dart engine into a Web Worker and does all the work in your browser tab. Nothing you type or drop in is uploaded, and the tools keep working offline once the page has loaded.