chacha20-poly1305 encrypt & decrypt online

Encrypt or decrypt text with chacha20-poly1305 and a secret. Nothing leaves your browser.

This mode needs an authentication tag.
Runs in your browser

PHP's openssl_encrypt needs a tag variable for this mode and returns no result without it. Like on the old site, the result stays empty. For working encryption use aes-256-cbc.

In short

What is chacha20-poly1305?

ChaCha20 is a stream cipher by Daniel J. Bernstein (2008, RFC 8439) with a 256-bit key. It is fast without special hardware and is used with Poly1305 in TLS 1.3, WireGuard and SSH. ChaCha20-Poly1305 is authenticated encryption: besides the ciphertext it produces a tag that proves nobody changed it. In PHP it needs a tag variable, so this tool, like the old site, gives no result.

Strong cipherChaCha20: No practical attack on the cipher itself is known.
Where you meet ChaCha20
  • TLS 1.3 (with Poly1305)
  • WireGuard VPN
  • OpenSSH
  • Chrome and Android on phones without AES hardware
Honest answer

Is it safe to use?

The cipher: strong cipher

ChaCha20. No practical attack on the cipher itself is known.

This setup: for compatibility

The setup of this tool is made for compatibility with PHP's openssl_encrypt, not for protecting secrets: the IV is always zero, the secret is used as the key without a key derivation function, and nothing detects changes to the ciphertext.

For real secrets use an authenticated mode such as AES-256-GCM or ChaCha20-Poly1305 with a fresh random nonce for every message, and derive the key from a password with Argon2id, scrypt or PBKDF2. What is a key derivation function?

Authenticated encryption (AEAD)

How authenticated modes work

Authenticated modes (GCM, CCM, OCB, Poly1305) encrypt and at the same time compute a tag over the data. Decryption checks the tag first and fails if anything was changed. This is what you want for real encryption.

PHP's openssl_encrypt only returns a result for these modes if you pass a variable for the tag and a nonce. The old site did neither, so the result was always empty, and this tool keeps it that way.

Common mistakes

Why chacha20-poly1305 gives no result

Why the result is empty

Authenticated modes need a nonce and produce a tag. PHP's openssl_encrypt returns false when you don't pass a tag variable, and the old site didn't. See the code example for how to use the mode correctly.

Reusing a nonce

In GCM, the same nonce twice with the same key reveals the XOR of the two texts and lets an attacker forge tags. Use 12 random bytes per message, or a counter that never repeats.

Throwing away the tag

The 16-byte tag is part of the message. Store or send it together with the nonce and the ciphertext; decryption without it is impossible, and skipping the check gives up the protection.

Which cipher was it?

Encrypted something here years ago?

Paste the Base64 result and the secret. Your browser tries all 174 ciphers of this site and shows those that give readable text. Useful if you don't remember the cipher, or to check whether your ciphertext really is chacha20-poly1305.

Nothing is sent anywhere. Wrong secrets give no readable text.
Compare

Every ChaCha20 variant, same input

The text The quick brown fox jumps over the lazy dog (43 bytes) with the secret my secret in all 2 ChaCha20 ciphers. The last column lists names that give the same result: aliases, and modes that agree for this input. Type a text and a secret in the tool above to use yours.

CipherResult (Base64)Same as
chacha20 RFwqGz16fU+vtgQUCclXTbDkO+C+seq8uGATh/b7VO9m6Xw14a0PrwCYBw==
chacha20-poly1305 no result
FAQ

Questions about chacha20-poly1305

Why is the chacha20-poly1305 result empty?

Because PHP's openssl_encrypt returns false for authenticated modes when no tag variable is passed, and the old site passed none. The tool keeps that behaviour so old results stay comparable. Use the code example to encrypt with a nonce and tag.

Is ChaCha20-Poly1305 secure?

Yes, when used correctly: ChaCha20-Poly1305 with a random, never repeated nonce and the tag checked on decryption is a recommended way to encrypt data today.

Good to know

Before you rely on it

Searches the list of pages on this site. What you type stays in your browser.