AES-128, 192 and 256
Choose the key size and the mode: AES-GCM with built-in tamper detection, or classic CBC and CTR.
Encrypt and decrypt text or files with AES-256-GCM, CBC or CTR, and see every step: salt, IV, derived key, ciphertext and authentication tag. It runs in your browser, so nothing is uploaded.
0 characters
These examples use the default settings (AES-256-GCM, password, PBKDF2-SHA256 with 600,000 iterations, Base64). We tested that they decrypt this tool's output and the other way around.
Run the AES and PBKDF2 code in your browser against official test vectors from NIST and other published standards.
AES, the Advanced Encryption Standard, is the encryption that protects most of the digital world. It secures your HTTPS connections, your Wi-Fi, your phone storage, your password manager, your cloud backups and the files on millions of laptops. Yet for most people, and even for many developers, it is a black box: you give it data and a key, and something unreadable comes out. Our free AES encryption demo opens that box. Type some text or choose a file, enter a password or your own hexadecimal key, pick AES-128, AES-192 or AES-256 and the mode GCM, CBC or CTR, and the tool encrypts or decrypts it right away. Then it shows you exactly what happened: the random salt, the key that PBKDF2 derived from your password, the initialization vector (IV), the ciphertext, the authentication tag and a color-coded picture of how these parts are packed together. You get an online AES encryption and decryption tool, a learning lab for students and a testing helper for developers, all in one page. Everything runs in your browser with the Web Crypto API, so your text, files and passwords are never uploaded. You can copy the result as Base64 or hex, decrypt it again, download encrypted files, run official NIST test vectors to verify the engine, and copy ready-to-use code for JavaScript, PHP and Python that works with the output of this tool.
Choose the key size and the mode: AES-GCM with built-in tamper detection, or classic CBC and CTR.
Inspect the salt, IV, derived key, ciphertext and tag, with a clear explanation of each step.
It all runs in your browser. Nothing you type or upload leaves your device.
The tool is built so that a beginner can encrypt something in half a minute, and an expert can control every parameter.
AES is a symmetric block cipher. Symmetric means that the same secret key is used to lock and to unlock the data, and block cipher means that it works on fixed blocks of 128 bits (16 bytes) at a time. It was created by the Belgian cryptographers Joan Daemen and Vincent Rijmen under the name Rijndael, was chosen by the US National Institute of Standards and Technology (NIST) after a public competition, and was published as the standard FIPS 197 in 2001. More than twenty years of worldwide analysis have found no practical attack against full AES, which is why it is trusted by governments, banks and every major technology company. The key can have three sizes: 128, 192 or 256 bits. The number of rounds of mixing inside the cipher grows with the key size: 10 rounds for AES-128, 12 for AES-192 and 14 for AES-256.
AES takes a 16-byte block and arranges it in a 4 by 4 grid. First it mixes in a part of the key. Then, in every round, it performs four operations. SubBytes replaces each byte with another one using a fixed lookup table, which hides the relation between input and output. ShiftRows moves the bytes of each row by a different amount. MixColumns blends the four bytes of each column together, so that one changed input byte affects many output bytes. AddRoundKey combines the grid with a new round key that is calculated from your main key. After the last round, the grid is the encrypted block. This repeated substitution and mixing creates what cryptographers call confusion and diffusion, and it makes the output look like random data. Because AES only encrypts one block, a mode of operation such as GCM, CBC or CTR decides how to handle messages that are longer than 16 bytes, and that choice is just as important as the key size.
The mode of operation defines how blocks are chained, and it decides whether your data is only hidden or also protected against changes.
| Mode | Authenticated | IV or nonce | Best for | Watch out for |
|---|---|---|---|---|
| AES-GCM | Yes, 128-bit tag | 12 bytes, never reuse with the same key | Almost everything: messages, files, APIs, TLS | Reusing a nonce destroys its security |
| AES-CBC | No | 16 random bytes | Compatibility with older systems | Needs padding, and can be attacked without a MAC (padding oracles) |
| AES-CTR | No | 16-byte counter block | Streaming and random access | Attackers can flip bits in the ciphertext unnoticed |
| AES-ECB | No | None | Nothing: avoid it | Identical blocks give identical output, which leaks patterns. This tool does not offer it. |
In short: use AES-GCM. It gives you confidentiality and integrity in one step. If decryption fails with AES-GCM, you know that the key was wrong or the data was modified, instead of getting garbage that looks like a valid result.
| Key size | Rounds | Hex key length | Security level |
|---|---|---|---|
| AES-128 | 10 | 32 characters | 128-bit: out of reach of brute force |
| AES-192 | 12 | 48 characters | 192-bit: very high margin |
| AES-256 | 14 | 64 characters | 256-bit: highest margin, also considered resistant to future quantum attacks on key search |
For a practical attacker, all three sizes are far beyond brute force. Trying every 128-bit key would take longer than the age of the universe on any computer that exists. AES-256 is the usual choice because it costs almost nothing extra and gives the largest safety margin. In reality, a weak password or a leaked key is the weak point, not the key size.
AES needs a key of exactly 128, 192 or 256 random bits, but people remember passwords, not random bits. A key derivation function (KDF) bridges the gap. This tool uses PBKDF2 with HMAC-SHA-256. It combines your password with a random 16-byte salt and repeats a hashing step hundreds of thousands of times, and the result is a key of the right size. The salt makes sure that two people with the same password get different keys, and the many iterations make every password guess slow for an attacker. A setting of 600,000 iterations follows the current OWASP guidance for PBKDF2-HMAC-SHA256. A stronger and slower option is available at 1,000,000. If you already have a random key from a secure generator, choose Raw key mode, and the tool uses it directly. A raw key must be exactly 32, 48 or 64 hex characters long, depending on the key size.
The result of the tool is not just ciphertext. To decrypt, you also need the salt and the IV, and they are not secret, so they are stored in front of the ciphertext. The layout is simple, and it is the same in the code examples on this page.
password mode: salt (16 bytes) + IV (12 bytes for GCM, 16 for CBC/CTR) + ciphertext [+ 16-byte tag for GCM]
raw key mode: IV + ciphertext [+ tag]
text output: the bytes above written as Base64 or hex
file output: the raw bytes, saved as name.ext.aes
The color-coded layout bar under the result shows these parts for your own data. Because the format is plain and documented, you can decrypt the output of this tool in your own PHP, Python, Node.js or browser code, and the other way around, which we tested with the examples above.
The code panel on this page contains complete encrypt and decrypt functions for AES-256-GCM with a password. In JavaScript, it uses the built-in Web Crypto API (crypto.subtle), which works in all modern browsers and Node.js. In PHP, it uses openssl_encrypt and hash_pbkdf2, and in Python it uses the widely used cryptography package. They produce the same data layout as the tool, so a text that you encrypt here can be decrypted by your server, and a value that your server encrypts can be decrypted here. This is useful for debugging encryption problems, for checking that two systems agree and for learning how the pieces fit together.
The most common reasons are a wrong password or key, a different algorithm or key size than the one used for encryption, a different number of PBKDF2 iterations, the wrong text format (Base64 instead of hex, or the opposite), extra characters or a line break that was added when the text was copied, and ciphertext that was shortened or modified. With AES-GCM the tool then reports a clear failure, because the authentication tag does not match. With CBC or CTR a wrong key can sometimes produce unreadable output instead of an error, and the tool tells you when the result is not valid text. Check each of these settings in turn, and use the Technical details panel to compare the salt and IV with the ones that you expect.
This tool is built for learning, testing and light everyday protection, and it uses the real, standard algorithms from your browser. It is not a replacement for audited, full-featured security software when the stakes are high. It does not manage keys for you, does not protect your device against malware or keyloggers, and cannot protect data that you have already shared in plain text. For critical secrets, business-grade storage or legal and medical records, use established tools such as a password manager, full-disk encryption or a vetted file encryption program, and follow your organization's security policy. Also remember that your password is the real lock: a weak one will be guessed, whatever the key size.
Our free AES encryption demo encrypts and decrypts text and files with AES-128, AES-192 and AES-256 in GCM, CBC and CTR modes, explains every step and runs entirely in your browser. Try it now, with no signup and no upload.
Quick answers about AES, its modes, passwords and keys, and how to use this encryption demo safely.
AES, the Advanced Encryption Standard, is a symmetric encryption algorithm that was standardized by NIST in 2001 (FIPS 197). The same secret key locks and unlocks the data. It works on 128-bit blocks and supports 128, 192 and 256-bit keys, and it protects HTTPS, Wi-Fi, disk encryption, password managers and many other systems.
AES-256 has a larger safety margin and is the usual recommendation, but both are secure against brute force with any technology that exists today. In practice, security depends far more on a strong password or a well-protected key than on the key size. This tool lets you choose 128, 192 or 256 bits, and AES-256 is the default.
Use AES-GCM. It encrypts and also authenticates the data with a tag, so any change or a wrong key is detected. CBC and CTR only hide the data and do not detect tampering, so use them only to match an older system. This tool does not offer ECB mode, because it leaks patterns in the data.
The encryption runs entirely in your browser with the standard Web Crypto API, and your text, files, passwords and keys are never uploaded to a server. The strength then depends on your password, so use a long and unique one. This is a learning and testing tool, so for highly sensitive data use audited security software and follow your organization's rules.
Yes. The output is the salt (16 bytes), the IV (12 bytes for GCM, 16 for CBC and CTR), the ciphertext and, for GCM, a 16-byte tag, written as Base64 or hex. The key comes from PBKDF2-HMAC-SHA256 when you use a password. The code panel gives you tested JavaScript, PHP and Python examples for the default settings that work with this tool in both directions.
The data cannot be recovered. AES has no back door and the tool does not store your password or key anywhere. Keep a safe backup of the password or key, for example in a password manager, before you rely on encrypted data.
The usual causes are a wrong password or key, a different algorithm, key size or PBKDF2 iteration count than the one used to encrypt, the wrong format (Base64 or hex), extra characters that came with the copied text, or ciphertext that was changed. Make sure that every setting matches the encryption, and check the salt and IV in the Technical details panel.
Merge, split, compress and convert files in seconds. Explore powerful free tools for all your everyday needs.
Explore All Tools →