AES Encryption and Decryption
Encrypt or decrypt text with AES-128, 192, or 256 in CBC, GCM, CTR, or ECB mode. Enter the key and IV as text, hex, or Base64.
Encryption and decryption run in your browser. The key, IV, plaintext, and ciphertext are never uploaded. Only the mode, key size, format, and padding choices are saved on this device, never the key, IV, plaintext, or ciphertext.
How to Use
- Choose the “Mode” and “Key size” to match your code. If you're unsure, GCM is the choice for new systems; older systems mostly use CBC.
- Pick the “Key format”, then enter the key: UTF-8 text for a readable key, Hex for hexadecimal, Base64 for Base64. The key must be exactly the right number of bytes: 16 for AES-128, 24 for AES-192, 32 for AES-256. If it isn't, you're told how long it is.
- Enter the IV: 16 bytes for CBC and CTR, at least 8 for GCM with 12 recommended. Press “Random” to generate one, then “Copy” to paste it into your code. ECB doesn't use an IV.
- Type in “Plaintext” to encrypt as you go, with the ciphertext appearing below. Paste into “Ciphertext” to decrypt the other way. Choose Base64 or hex for the ciphertext, and PKCS#7 or no padding, which applies only to CBC and ECB.
- The 16-byte GCM tag is appended to the ciphertext. When decryption fails, the error tells you whether the key, IV, ciphertext length, padding, or authentication is the problem.
- Only the mode, key size, format, and padding choices are saved on this device, never the key, IV, plaintext, or ciphertext.
AES Encrypt and Decrypt: A Worked Example
Here is one encryption you can reproduce on this page. Set the mode to CBC and the key size to 128. Set the key format to UTF-8 text and the IV format to hex, then enter these test values.
| Field | Value |
|---|---|
| Key (16 characters) | 0123456789abcdef |
| IV (hex, 16 bytes) | 000102030405060708090a0b0c0d0e0f |
| Plaintext | Hello, AES! |
| Padding | PKCS#7 |
| Ciphertext, Base64 | zge8cMU4MgP2xclSfrb2fQ== |
| Ciphertext, hex | ce07bc70c5383203f6c5c9527eb6f67d |
Paste the ciphertext into the “Ciphertext” box with the same key, IV, and settings, and Hello, AES! comes back. If one setting is different, such as the mode or the key format, the result is different or decryption fails with an explanation.
These values are only for trying the tool. Never use a key like this for real data, and never reuse an IV with the same key.
Key and IV Lengths
| Setting | Length |
|---|---|
| AES-128 key | 16 bytes |
| AES-192 key | 24 bytes |
| AES-256 key | 32 bytes |
| IV for CBC and CTR | 16 bytes |
| IV for GCM | At least 8 bytes, 12 recommended |
| IV for ECB | Not used |
If a length is wrong, the page tells you how many bytes you entered. A key typed as UTF-8 text is counted in bytes, so a character outside basic English letters may take more than one.
FAQ
How do I encrypt text with AES online?
Choose the mode and key size, enter a key of the right length and an IV, then type your text in “Plaintext”. The ciphertext appears below as you type, in Base64 or hex. To decrypt, paste the ciphertext into “Ciphertext” with the same key, IV, and settings. There is a worked example further down the page.
Is this AES tool free, and do I need to sign up?
Yes, it's free, with no account and nothing to install. You can use it on a phone or a computer for AES-128, AES-192, and AES-256 in CBC, GCM, CTR, and ECB.
What is AES, and how is it different from Base64 or a hash?
AES is the most widely used symmetric encryption algorithm: a secret key turns data into unreadable ciphertext, and only someone with the same key can decrypt it. Base64 is an encoding with no key, so anyone can decode it and it keeps nothing secret. A hash is a one-way digest that can't be turned back into the original and uses no key. When content must be readable only by specific people, you need encryption like AES.
Should I use CBC, GCM, CTR, or ECB?
For new systems, use GCM. Besides encrypting, it adds an authentication tag, so decryption fails outright if the ciphertext was altered or the key is wrong. CBC is the most common older mode; it needs padding and doesn't detect tampering. CTR uses AES as a stream cipher with no padding and also doesn't detect tampering. ECB turns identical plaintext blocks into identical ciphertext blocks, leaking patterns, so use it only to match legacy systems. When checking existing code, choose the same mode it uses.
What is an IV, and can it be public?
The IV (initialization vector) makes encrypting the same content with the same key produce different ciphertext each time. It doesn't need to be secret and is usually sent or stored with the ciphertext, but it must never be reused with the same key. Reusing an IV with GCM or CTR is especially dangerous and can reveal the plaintext. Generate a fresh random IV for every encryption, for example with this tool's “Random” button.
Why doesn't my ciphertext match my code's output?
Check each of these: the same mode and key size; the right key and IV formats, since the same characters read as text or hex are completely different bytes; matching padding, where Java's PKCS5Padding is the same as PKCS#7 for AES; Base64 versus hex output; and whether the GCM tag is appended to the ciphertext or stored separately. A single different byte changes the whole ciphertext.
Can I decrypt CryptoJS passphrase output (starting with U2FsdGVkX1) here?
Not directly. When CryptoJS gets a string as the key, it treats it as a passphrase and uses an old OpenSSL method to derive the real key and IV from it with a random salt, then puts the salt at the start of the ciphertext. U2FsdGVkX1 is “Salted__” in Base64. This tool takes the key and IV directly and doesn't derive them from a passphrase. If your code passes the key and IV as WordArrays, you can compare the results here.
Are my key and data uploaded?
No. Encryption and decryption run only in your browser, and the key, IV, plaintext, and ciphertext are never sent to a server, so even a production key never passes through this site. Only your mode, key size, format, and padding choices are saved on this device, never the key or content, so the next person on a shared computer won't see them.
Related Tools
HMAC Generator
Enter a message and a key to get an HMAC with SHA-256, SHA-384, SHA-512, SHA-1, or MD5. The key can be text, hex, or Base64.
Password-Protect Text
Lock a message with a password and get locked text or a share link. Only someone with the same password can read it.
Hash Generator
Enter text or choose a file to get MD5, SHA-1, SHA-256, SHA-384, and SHA-512 at once. Paste an expected value to see which algorithm matches.
Caesar Cipher & ROT13
Type in either box to encrypt or decrypt English letters with a shift, switch to ROT13 in one tap, and see the results for all 25 shifts at once.
Base64 Encoder & Decoder
Type in either box to encode text as Base64 or decode Base64 back into text. UTF-8 safe, with a URL-safe alphabet option.
Password Generator
Generate strong random passwords in one click. Choose the length and character types, up to 10 at a time.
Text to Binary & Hex Converter
Type in either box to turn text into the binary, octal, decimal, and hex of each UTF-8 byte, or decode those bytes back into text.