Encrypt text with AES-128-CBC
This tool encrypts a piece of text with AES, a 128-bit key and CBC mode. You type the text, the key and, if you want, an initialization vector (IV). The ciphertext comes back Base64-encoded, with a button to copy it.
Use it to test, to learn, or to check that your own code produces the same output as OpenSSL. The work is done on the server by PHP's openssl_encrypt function with PKCS#7 padding.
How to use it
- Type the text to encrypt in the first box.
- Enter the key in the Salt field. Despite the label, this field is the key. AES-128 expects 16 bytes, which means 16 ASCII characters.
- Enter a 16-character IV in the IV (optional) field, or leave it empty.
- Click Encrypt, then Copy to grab the Base64 result.
Both the text and the key are required. If one is missing, the tool shows "error".
How AES-128-CBC works
AES cuts the message into 16-byte blocks. In CBC mode (Cipher Block Chaining), each block is XORed with the previous encrypted block before being encrypted itself. The first block has no predecessor, so it is XORed with the IV. As a result, two identical plaintext blocks do not give the same ciphertext, and a different IV changes the whole output. To see the opposite effect, encrypt two identical blocks on the encrypt AES 128 ECB page.
With a 128-bit key, AES runs 10 rounds on every block. It is the fastest of the three key sizes and is still considered secure, so it is a sensible default unless a standard requires 192 or 256 bits.
Padding always adds between 1 and 16 bytes. The word Hello (5 bytes) fits in one block: 16 encrypted bytes, or 24 Base64 characters. A text of exactly 16 bytes produces two blocks, or 44 characters.
The equivalent PHP call:
openssl_encrypt($text, 'aes-128-cbc', '0123456789abcdef', 0, 'fedcba9876543210');
A key shorter than 16 bytes is padded with null bytes. A longer key is cut off after 16 bytes.
Frequently asked questions
What happens if I leave the IV empty?
The tool falls back to a fixed default IV. That is fine for a quick trial, but the same text with the same key will always give the same result. In real use, generate a random IV for every message and send it along with the ciphertext. The IV does not have to be secret.
Is my data stored?
The text and the key are sent to the server over HTTPS for the calculation and are not saved. To stay on the safe side, do not encrypt production secrets here. Use test values.
Is the ciphertext protected against tampering?
No. AES-CBC gives confidentiality, not integrity. A ciphertext altered in transit can still decrypt without any error. To detect changes you need to add an HMAC or use an authenticated mode such as AES-GCM, which this tool does not offer. The site's SHA256 generator can compute an HMAC for your tests.
How do I get the original text back?
Use the site's decrypt AES 128 CBC page with the same key and the same IV.