How to use the aes encrypt decrypt
- Choose Encrypt or Decrypt, then the block mode: CBC, ECB or CTR.
- Enter the key as hex or text. A 16-byte key selects AES-128, 24 bytes AES-192 and 32 bytes AES-256.
- For CBC and CTR enter the 16-byte IV or initial counter. ECB ignores it.
- Paste the input and set its format: text, hex or base64. Decrypt expects ciphertext.
- Pick the output format and read the result below. Padding errors mean the key, IV or mode does not match.
How AES encryption works
AES (Advanced Encryption Standard) is a symmetric block cipher that processes data in 16-byte blocks. The number of rounds depends on the key size: AES-128 uses 10 rounds, AES-192 uses 12 rounds and AES-256 uses 14 rounds. Each round applies four transformations to the state matrix: SubBytes substitutes each byte using a fixed S-box, ShiftRows cyclically shifts the rows, MixColumns multiplies columns by a fixed polynomial in GF(28) and AddRoundKey XORs the state with a round key derived from the main key.
The key schedule expands the original key into round keys. For AES-128, the 16-byte key produces 11 round keys of 16 bytes each. The expansion uses the RotWord, SubWord and Rcon operations defined in FIPS 197. Because AES is symmetric, decryption reverses these steps using InvSubBytes, InvShiftRows and InvMixColumns, except in CTR mode where decryption is identical to encryption.
Block cipher modes explained
The block mode determines how multiple 16-byte blocks are chained together. Choosing the right mode is critical for security.
| Mode | Description | Padding needed |
|---|---|---|
| ECB | Each block is encrypted independently. Identical plaintext blocks produce identical ciphertext blocks, which leaks patterns. | Yes (PKCS7) |
| CBC | Each plaintext block is XORed with the previous ciphertext block before encryption. Requires a random 16-byte IV for every message. | Yes (PKCS7) |
| CTR | Turns AES into a stream cipher. A counter block is encrypted and XORed with the plaintext. No padding is required and the IV acts as a nonce combined with a counter. | No |
For most applications, CTR or CBC is preferred over ECB. ECB should only be used when encrypting single blocks or when pattern leakage is acceptable, such as encrypting random identifiers.
Key and IV formatting
Keys and IVs are entered as hex bytes or as UTF-8 text, selected with the format boxes. The key length picks the variant: 16 bytes gives AES-128 (32 hex characters), 24 bytes gives AES-192 (48 hex characters) and 32 bytes gives AES-256 (64 hex characters). A passphrase typed as text must be exactly one of those byte lengths, otherwise the tool reports the length it found.
The IV is always 16 bytes for CBC. In CTR mode the 16-byte value is the initial counter block and is incremented as one 128-bit big-endian number, which is the convention used in NIST SP 800-38A and in common libraries. ECB does not use an IV.
If you need to derive a key from a password rather than typing raw bytes, run it through a key derivation function first. You can create suitable keys with the PBKDF2 generator or random secrets with the API key generator.
PKCS7 padding details
ECB and CBC modes require the plaintext length to be a multiple of 16 bytes. PKCS7 padding adds N bytes, each with the value N, where N is the number of bytes needed to reach the next block boundary. If the plaintext is already a multiple of 16 bytes, a full block of 16 bytes (each with value 0x10) is appended.
For example, the 5-byte string "Hello" needs 11 bytes of padding. Each padding byte will have the value 0x0B. During decryption, the last byte of the decrypted output tells the tool how many padding bytes to remove. If the padding is invalid, decryption fails with an error. CTR mode operates as a stream cipher and does not use padding at all.
Verifying against NIST test vectors
NIST Special Publication 800-38A lists known-answer vectors for every mode here. Encrypting the plaintext block 6bc1bee22e409f96e93d7e117393172a with AES-128 in ECB mode and the key 2b7e151628aed2a6abf7158809cf4f3c gives 3ad77bb40d7a3660a89ecaf32466ef97. Set the key and input formats to hex and the padding to None to reproduce it.
The AES-128 CBC vector uses the IV 000102030405060708090a0b0c0d0e0f and gives 7649abac8119b246cee98e9b12e9197d for the same first block. For CTR, the initial counter f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff gives 874d6191b620e3261bef6864990db6ce. Padding is switched off in these vectors because the plaintext is already a whole number of blocks.
Common mistakes to avoid
When performing AES encryption online or offline, several pitfalls can compromise security or cause errors:
- Reusing an IV with the same key. In CBC and CTR modes, reusing an IV allows attackers to deduce relationships between plaintexts. Always generate a fresh random IV for every encryption operation.
- Using ECB for structured data. ECB encrypts each block independently, meaning identical plaintext blocks produce identical ciphertext blocks. Images encrypted with ECB still reveal their outlines.
- Confusing hex and text keys. Entering a 16-character ASCII password when the tool expects 32 hex characters for AES-128 will produce incorrect results. Always verify the key format.
- Ignoring padding errors on decryption. If PKCS7 padding is invalid after decryption, the key, IV or ciphertext is likely wrong. Do not strip bytes manually.
- Treating AES as authentication. CBC, ECB and CTR give confidentiality only. Anyone can flip bits in the ciphertext without detection, so real systems add an HMAC (see the HMAC SHA256 generator) or use an authenticated mode such as GCM.
For simpler obfuscation needs, tools like XOR encryption exist, but they do not provide the cryptographic guarantees of AES.
Worked examples
| Example | Input | Result |
|---|---|---|
| AES-128 CBC text | Operation: encrypt; Block mode: CBC; Key: 2b7e151628aed2a6abf7158809cf4f3c; Key format: hex; IV / initial counter: 000102030405060708090a0b0c0d0e0f; IV format: hex; Input: Hello, AES!; Input format: text; Padding (ECB and CBC): pkcs7; Output format: hex | Ciphertext (hex): 4595c7eb3a014951b23c1bf8f4419938; Cipher: AES-128-CBC with PKCS7; Output length: 16 bytes |
| AES-256 ECB to base64 | Operation: encrypt; Block mode: ECB; Key: 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4; Key format: hex; IV format: hex; Input: attack at dawn; Input format: text; Padding (ECB and CBC): pkcs7; Output format: base64 | Ciphertext (base64): pn/8DPDgNsNdAE84yPNNdA==; Cipher: AES-256-ECB with PKCS7; Output length: 16 bytes |
| Decrypt back to text | Operation: decrypt; Block mode: CBC; Key: 2b7e151628aed2a6abf7158809cf4f3c; Key format: hex; IV / initial counter: 000102030405060708090a0b0c0d0e0f; IV format: hex; Input: 4595c7eb3a014951b23c1bf8f4419938; Input format: hex; Padding (ECB and CBC): pkcs7; Output format: text | Plaintext (text): Hello, AES!; Cipher: AES-128-CBC with PKCS7; Output length: 11 bytes |
| NIST CTR test vector | Operation: encrypt; Block mode: CTR; Key: 2b7e151628aed2a6abf7158809cf4f3c; Key format: hex; IV / initial counter: f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff; IV format: hex; Input: 6bc1bee22e409f96e93d7e117393172a; Input format: hex; Padding (ECB and CBC): pkcs7; Output format: hex | Ciphertext (hex): 874d6191b620e3261bef6864990db6ce; Cipher: AES-128-CTR; Output length: 16 bytes |
FAQ
Is this AES encryption online tool secure?
The computation runs locally in your browser with a pure TypeScript implementation, and your plaintext, key and ciphertext are never sent anywhere. The modes offered here do not authenticate the data, so add an HMAC if tampering matters.
What is the difference between AES-128, AES-192 and AES-256?
The numbers are the key length in bits. AES-128 uses a 16-byte key and 10 rounds, AES-192 a 24-byte key and 12 rounds, and AES-256 a 32-byte key and 14 rounds. In this tool the key length you enter selects the variant.
Why does ECB mode not require an IV?
ECB (Electronic Codebook) encrypts each 16-byte block independently without chaining. There is no previous block state to mix in, so no initialization vector is needed. This independence is also why ECB leaks patterns.
Can I use a password instead of a hex key?
Yes. Set the key format to Text and type the password. The tool encodes it as UTF-8, and the byte length must be exactly 16, 24 or 32. For variable-length passwords, derive a key with PBKDF2 first.
Why does CTR mode decryption look the same as encryption?
CTR mode generates a keystream by encrypting successive counter values and XORs that keystream with the data. Since XOR is its own inverse, applying the same operation again recovers the original data. The tool handles this automatically when you select Decrypt.
What happens if my ciphertext is not valid hex or base64?
The tool will return an error. When decrypting, ensure the input matches the selected input format. Hex inputs must contain only characters 0-9 and a-f, and base64 inputs must use standard base64 characters.