deftools.io Security

AES Encrypt / Decrypt

Encrypt and decrypt text with AES-256-GCM using a passphrase or a raw key. Portable base64 output.

Derive a 256-bit AES key from your passphrase with PBKDF2 + SHA-256.
0 B
The base64 envelope packs v1, salt, IV, and ciphertext into a single string you can paste back to decrypt.
Copied!

About this tool

This tool encrypts text with AES-256-GCM, the authenticated symmetric cipher recommended for protecting data at rest and in transit. You can either derive the key from a passphrase with PBKDF2 (with a salt and many thousands of iterations, so a stolen ciphertext is useless without the passphrase), or supply a raw 128/256-bit key in hex or base64.

Because AES-GCM is authenticated, tampering with the ciphertext — flipping a single bit — makes decryption fail outright instead of producing corrupted plaintext. The output is a self-contained v1:… envelope that bundles the salt, IV, and ciphertext into one string, so the recipient only needs the passphrase to decrypt. Example: Hello with passphrase s3cretv1:eyJ2IjoxLCJzIjoi…","i":"…","c":"…"}.

Use it to protect config secrets, share a note over an untrusted channel, or verify that a ciphertext you already have decrypts cleanly. The passphrase never leaves your browser.

FAQ

What happens if I use the wrong passphrase?

Decryption fails with an authentication error. AES-GCM verifies an integrity tag before returning plaintext, so a wrong key (or any tampered ciphertext) is rejected outright instead of producing garbled text.

Why does the output change every time I encrypt the same text?

Each encryption draws a fresh random salt and IV, so identical inputs produce completely different ciphertexts. This is correct and necessary — reusing an IV with the same key would leak information.

How many PBKDF2 iterations should I use?

At least 250,000 for SHA-256 on a modern machine; 600,000 matches the OWASP 2023 guidance. More iterations slow down brute-force attacks at the cost of a slightly slower encrypt/decrypt. The iteration count is stored inside the envelope, so the recipient never has to guess it.

Is this safe for passwords and secrets?

Yes for ad-hoc encryption in your browser, but for production systems prefer a dedicated key-management service (AWS KMS, HashiCorp Vault). Never commit passphrases alongside ciphertexts.

Related security tools

Copied!