Encrypt / Decrypt Text

Crypto

Encrypt and decrypt text with AES-GCM using a passphrase via the browser-native Web Crypto API. Keys use PBKDF2 and a fresh salt each run. Base64 output.

Ready
Plain
13 chars
Cipher
0 chars

About Encrypt / Decrypt Text

When you want to lock a piece of text so only someone with the passphrase can read it, you need symmetric encryption. This tool implements AES encryption/decryption with the browser's Web Crypto API: you enter plaintext and a passphrase, the tool derives a key from the passphrase via a KDF like PBKDF2. Then encrypts in AES-GCM mode and outputs ciphertext with a random IV (usually Base64).Decryption with the same passphrase restores it. Everything runs locally, and plaintext, passphrase, and key never leave the browser, making it ideal for temporarily encrypting a note, config, or secret before sending it over an ordinary channel. With passphrase encryption, security rests on how the passphrase becomes a key rather than on how advanced the algorithm name sounds. Using the passphrase directly as a key weakens it sharply, since the passphrase space is far smaller than the key space, so a dedicated derivation step adds cost and randomness. That tells you whether to trust an implementation: does it derive, and is the cost configurable. The same plaintext should produce different ciphertext each time, another key indicator of implementation quality. That requires a fresh random initial value stored alongside the ciphertext, and a fixed or reused one makes identical content produce identical output, letting an observer tell whether two pieces match. Confirm how the random value is generated and stored. Confidentiality without integrity is not enough, and this is often overlooked. Tampered ciphertext can decrypt to meaningless content, and without an integrity check the system cannot tell a modified message from a wrong passphrase. Prefer authenticated encryption so decryption fails clearly when content was altered instead of returning a plausible-looking error result. Cipher modes differ in security and usage and should be chosen with their trade-offs understood. Block modes need a non-reusable random value and process chunk by chunk with ordering constraints, while streaming authenticated modes combine encryption and verification for simpler use but demand the random value never repeat. Managing that value often fails before the algorithm does. Ciphertext and passphrase must travel through separate channels, the step most often broken in process. Putting both in one e-mail or chat window makes the encryption largely cosmetic. Define which route carries the ciphertext and which carries the passphrase, and write it into the instructions rather than relying on whoever handles it. Finally, the result cannot be judged by eye, so build a verifiable round trip. Decrypting immediately and comparing against the original catches a mistyped passphrase, an encoding mistake or an incomplete copy before delivery; without that step the problem surfaces only when the recipient cannot decrypt, and costs far more to trace.

How It Works Internally

Symmetric encryption uses one key for both directions, and the key is usually derived from a passphrase through a stretching function. Each encryption generates a fresh random initialization vector stored with the ciphertext, so identical plaintext and passphrase yield different ciphertext — a necessary semantic security property rather than a defect: identical outputs would let an attacker compare ciphertexts to learn whether two plaintexts match.

InputPlaintext "hello", passphrase "pw"
OutputTwo runs give different ciphertext and IV; decrypting either with the same passphrase yields "hello"

Measured on This Page

Page to PythonAll five plaintexts (ASCII, Chinese, emoji, 1KB, empty) decrypted in Python byte-identical to the original
Python to pageTwo ciphertexts produced in Python, including Chinese, decrypted correctly by the page
Wire formatBase64 decodes to salt 16 bytes + iv 12 bytes + ciphertext, which is 16 bytes longer than the plaintext — the GCM tag
Auth failureWrong passphrase and tampered ciphertext both refuse to output, with identical messages — AES-GCM cannot tell them apart by design
ParametersPBKDF2-SHA256 with 150,000 rounds deriving a 256-bit key, AES-GCM, random salt and iv

150,000 rounds is a 2020-era figure; OWASP 2023 recommends 600,000 for PBKDF2-HMAC-SHA256. This page stays at 150k because the wire format has no version field, so raising it would make every existing ciphertext undecryptable. Treat it as a way to lock a message with a passphrase for someone else, not as long-term archival encryption — the real strength comes from the passphrase.

How this was measured: Cross-implementation check in both directions: page output was decrypted by Python cryptography directly (PBKDF2-HMAC-SHA256 150,000 rounds to AES-256-GCM, splitting salt/iv/ciphertext per the wire format), then ciphertext produced in Python was fed back into the page; wrong passphrase, tampered ciphertext and empty input were also tested. · Measured 2026-10-28

How to Use

  1. Open "Encrypt / Decrypt Text"
  2. Switch between Encrypt and Decrypt at the top
  3. Enter the passphrase and put the plaintext in the input box
  4. The ciphertext appears automatically; use the copy button
  5. To decrypt, paste the ciphertext with the same passphrase

Use Cases

  • Encrypt sensitive notes — Turn a memo with passwords or keys into ciphertext so it is safe even in an ordinary notes app.
  • Pass secure messages — Encrypt a message, send it via chat, and share the passphrase over a separate channel like a phone call.
  • Protect config snippets — Encrypt connection strings before pasting into a ticket or doc to avoid plaintext exposure.
  • Learn symmetric crypto — Observe how ciphertext changes with different passphrases and IVs for the same plaintext.
  • Temporary archiving — Encrypt sensitive text you do not need now, then decrypt with the passphrase later.
  • Share credentials — Encrypt a password or API key and send the ciphertext over email, then share the passphrase by phone.
  • Client-side decrypt — Decrypt a config file that was encrypted offline to inspect its contents without server-side tools.

FAQ

Which encryption algorithm is used?

The tool uses AES-GCM, a modern authenticated encryption mode that attaches an integrity tag while encrypting; if the ciphertext is tampered with, decryption simply fails, making it safer than encrypt-only CBC.

Is the passphrase used directly as the key?

No. The passphrase is first run through PBKDF2 with a random salt and many iterations to derive a fixed-length key, which resists rainbow tables and slows brute force on weak passphrases.

Why does the same text yield different ciphertext each time?

A fresh random IV (initialization vector) is used each time. This is a security feature preventing attackers from inferring repeated plaintext; the IV is read back alongside the ciphertext on decryption.

Can I decrypt if I forget the passphrase?

No. Without the passphrase the key cannot be derived and the ciphertext is mathematically unrecoverable. The tool stores no passphrase and has no recovery backdoor, so remember it.

Is this the same as Base64 encoding?

Not at all. Base64 is reversible encoding anyone can decode and offers no secrecy; encryption needs a key to reverse. If you only want encoding, use our Base64 tool.

Encrypting the same text and password twice gives different results. Why?

That is correct behaviour: each encryption generates a fresh random initialization vector stored alongside the ciphertext, so identical input still yields different output. If two runs produced identical output it would mean the vector is fixed, which is unsafe because an attacker could compare ciphertexts to learn whether two plaintexts match. Decryption needs only the ciphertext and password, since the vector travels with it.

Can the data be recovered if the password is lost?

No. The key is derived from the password, so without it the key cannot be reconstructed, and there is no backdoor or recovery path, which is exactly the security premise. Store the password separately from the ciphertext, for instance ciphertext in a file and password in a password manager, and if losing it would be catastrophic, design key escrow up front rather than looking for a rescue afterwards.

Ciphertext differs every time even with the same input — can it still be decrypted?

Yes. Modern modes (AES-GCM) use a random IV/nonce per encryption, so identical plaintext yields different ciphertext — that is the source of security. The IV travels with the ciphertext and is read automatically; the extra size is the IV plus the auth tag.