How to encrypt and decrypt AES text

One text box and one passphrase box: Encrypt turns plaintext into an AES ciphertext that starts with U2FsdGVkX1, and Decrypt reads such a ciphertext back as UTF-8 text. Both run inside the page — the round trip still works with the network switched off.

The key is not stored anywhere. It is derived from the passphrase and a fresh random salt on every run, which is why the same text with the same passphrase gives a different string each time.

  1. Paste the text you want to encrypt, or an existing ciphertext that starts with U2FsdGVkX1, into the box at the top.
  2. Type the passphrase in the field next to the buttons. It is the only secret: the same passphrase is needed to read the result back.
  3. Press Encrypt or Decrypt. The new result replaces the previous one, and a failed run clears the output instead of leaving the old text on screen.
  4. Confirm the result with a second tool when it matters: openssl enc -d -aes-256-cbc -md md5 -a -pass pass:YOURPASSPHRASE decrypts a ciphertext produced here.
  5. Press Clear to empty the text, the passphrase and the result before the next run.

What the output really is

The Salted__ container and its random salt

The result is Base64 whose first bytes decode to Salted__, followed by eight random bytes of salt and then the ciphertext. Key and IV are derived from the passphrase and that salt with EVP_BytesToKey and MD5 — the scheme openssl enc has always used for passphrase encryption.

Because the salt is new on every run, the same sentence encrypts to a different string each time and both strings decrypt back to the same text. Checked in both directions: openssl reads the output of this page, and this page reads the output of openssl enc -aes-256-cbc -md md5.

What the page cannot check

The algorithm is AES-256-CBC and the container carries no signature or authentication tag. A wrong passphrase, a truncated string and an edited byte therefore end in the same message, and an edited ciphertext can still come out as unreadable text: in a test of six random single-character changes, five failed and one returned garbage without a warning.

Key derivation is a single MD5 pass over the passphrase, without the work factor that PBKDF2 or Argon2 add. The passphrase is therefore the weak point, and it is the reason this page suits reproducing and inspecting existing AES data rather than protecting new secrets.

Compatibility and limits

Text in, text out: files, binary data and hex input are not handled here. A ciphertext only decrypts when it is this salted passphrase container in CBC mode — output made with -nosalt, with an explicit -K and -iv, with another mode such as ECB, or by a different library fails with the same message.

200 KB of text encrypts in about 15 ms in Chrome; for inputs of several megabytes a local command-line tool is the better fit.

Recent tools: