What is text encryption?
Encryption turns readable text into unreadable bytes using a secret key, and only someone with the right key can turn it back. It is the opposite of hashing: a hash is a one-way fingerprint, while encryption is meant to be reversed, which is why you use it for data you need to read again, such as a token stored in a config file, a note you want to send to a colleague or a field you encrypt before saving it.
This page encrypts and decrypts text with AES, ChaCha20-Poly1305, XChaCha20-Poly1305, TripleDES, Rabbit and RC4, in two cards: one to encrypt, one to decrypt, with a button that sends the encrypted result straight to the decrypt card. There are two ways to give it a key. In passphrase mode you type any text and the page derives the real key from it, exactly as the openssl enc command does, so the output is compatible with OpenSSL: it starts with Salted__, which in Base64 appears as U2FsdGVkX1. In raw key mode you control everything yourself: the key in hex, Base64, UTF-8 or Latin-1, the mode (CBC, ECB, CTR, CFB, OFB or AES-GCM), the padding, the IV and, for GCM, the authenticated data. That second mode is what you need to reproduce what a specific library or API does.
ChaCha20-Poly1305 (RFC 8439) and XChaCha20-Poly1305 are modern authenticated ciphers, the same family TLS 1.3 and libsodium use. They need a raw 32-byte key and a nonce that must never repeat with the same key (12 bytes, or 24 for XChaCha20). The output is the ciphertext followed by a 16-byte tag, and the additional authenticated data can be typed as text or as hex, which is how the RFC 8439 test vectors are written.
Everything runs in your browser; the text and the key are never sent anywhere. It is a tool for development and for checking interoperability, not for managing production keys. It is symmetric (one shared key for both directions); for public-key pairs, see the RSA key pair generator. For the key itself, the token generator makes strong random values, and to store passwords, use hashing instead, as in the bcrypt tool.
How to encrypt and decrypt text online
- In the Encrypt card, type the text in The text to encrypt. The page opens with
Lorem ipsum dolor sit amet. - Type the secret key (the passphrase) and pick the algorithm. AES is the default and the right choice; Rabbit and RC4 are legacy, and the page says so.
- The encrypted text appears under Your text encrypted, in Base64. Open Key, IV and format options to switch the output to hex or change the key derivation.
- Press Send to Decrypt to move the result to the Decrypt card, or copy it.
- In the Decrypt card, paste the encrypted text, use the same key, algorithm and options, and read Your decrypted text.
- For control over the details, change Key type to the raw key and fill in the key (with the generate-random-key button), mode, padding and IV. With GCM you can add additional authenticated data and choose to have a random IV written at the start of the output.
Examples
Decrypt the sample
The Decrypt card opens with this text and the key my secret key:
U2FsdGVkX1/EC3+6P5dbbkZ3e1kQ5o2yzuU0NHTjmrKnLBEwreV489Kr0DIB+uBsThe result is Lorem ipsum dolor sit amet. Encrypting again with the same key gives different text each time, because a random salt is part of the output, and it still decrypts correctly.
Raw key: AES-256-CBC
Key type raw key, AES, mode CBC, padding PKCS#7, key as hex (32 bytes) and IV as hex (16 bytes):
key 1111111111111111111111111111111111111111111111111111111111111111
iv 22222222222222222222222222222222
text Hello, toolbox
out 8WfvAf+cGCcYCdnGQk1cGQ==The command printf 'Hello, toolbox' | openssl enc -aes-256-cbc -K 1111111111111111111111111111111111111111111111111111111111111111 -iv 22222222222222222222222222222222 | base64 prints the same value.
Why ECB leaks patterns
In ECB mode, the same block always encrypts to the same bytes. With key 000102030405060708090a0b0c0d0e0f (hex, AES-128) the text Hello, toolbox gives MAHbqpr0MPPPcz9OqHBXig==. Repeating a 16-byte block in the text repeats its ciphertext, so structure shows through. Use ECB only to reproduce old systems.
AES-GCM with authenticated data
AES-128-GCM, key 000102030405060708090a0b0c0d0e0f, IV a0a1a2a3a4a5a6a7a8a9aaab, additional data v1, text Hello, toolbox:
4uNU1xGlE37lF9liKWo9iOoNjkHxTv5TahKl/DiFThe 30 bytes are the 14 of ciphertext plus a 16-byte authentication tag. Change a single character of the output, or the additional data, and decryption fails instead of returning garbage.
Common errors and how to fix them
- "Unable to decrypt. Check that the text is the encrypted output (Base64), that the secret key is the same one used to encrypt, and that the algorithm matches.": the usual cause is a different key, algorithm, key derivation or output format. In passphrase mode all four must match.
- "AES needs a key of 16, 24, 32 bytes; this one has N.": in raw key mode the key must have exactly 16, 24 or 32 bytes (TripleDES: 16 or 24). Use the generate-random-key button or fix the encoding.
- "This mode needs an IV of 16 bytes.": every mode except ECB needs an IV. Type one or generate it.
- "Authentication failed. The key, the IV or the additional data do not match, or the text was changed.": AES-GCM detected tampering or a mismatch.
- "The input is not valid in the chosen format.": you chose Base64 but pasted hex, or the reverse.
- It decrypts to garbage in another library: the padding, mode or key derivation differs. The passphrase mode offers the old OpenSSL derivation (MD5, one round) and PBKDF2 (SHA-256, 10,000 rounds, like
openssl enc -pbkdf2); pick the one the other side used.
Frequently asked questions
What is the difference between encryption and hashing?
Encryption is reversible with the key; hashing is not. Use encryption for data you must read back, and hashing, such as the hash generator, for fingerprints and password verification.
Which algorithm and mode should I use?
AES, preferably AES-256 in GCM mode, which also detects tampering. Never reuse an IV with the same key in GCM. TripleDES, Rabbit and RC4 survive for compatibility only.
Is encrypting here safe?
The operation runs locally, so nothing is transmitted. Whether the result is safe depends on your key: a short or guessable passphrase can be cracked even if the algorithm is strong.
Is Base64 encryption?
No. Base64 only changes the representation of bytes, and anyone can reverse it with the Base64 tool. Encrypted output is often shown in Base64 so it can travel as text.
Encrypt and decrypt in code
JavaScript
import { createCipheriv, createDecipheriv } from 'node:crypto';
const key = Buffer.alloc(32, 0x11);
const iv = Buffer.alloc(16, 0x22);
const cipher = createCipheriv('aes-256-cbc', key, iv);
const encrypted = Buffer.concat([cipher.update('Hello, toolbox'), cipher.final()]).toString('base64');
const decipher = createDecipheriv('aes-256-cbc', key, iv);
console.log(Buffer.concat([decipher.update(encrypted, 'base64'), decipher.final()]).toString());Python
# pip install cryptography
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
key, iv = bytes([0x11]) * 32, bytes([0x22]) * 16
padder = padding.PKCS7(128).padder()
data = padder.update(b'Hello, toolbox') + padder.finalize()
enc = Cipher(algorithms.AES(key), modes.CBC(iv)).encryptor()
print((enc.update(data) + enc.finalize()).hex())Go
// import "crypto/aes", "crypto/cipher"
block, _ := aes.NewCipher(key) // 32-byte key
gcm, _ := cipher.NewGCM(block)
sealed := gcm.Seal(nil, nonce, []byte("Hello, toolbox"), nil) // nonce: 12 random bytesBash
printf 'Hello, toolbox' | openssl enc -aes-256-cbc -a -pbkdf2 -k 'my secret key'