ChaCha20 Encrypt/Decrypt

Encryption

Processed locally in your browser using the Web Crypto API. Nothing is sent to any server.

How It Works

This tool provides ChaCha20 and ChaCha20-Poly1305 encryption and decryption using the @noble/ciphers library. All cryptographic operations happen locally in your browser — your key, nonce, and data never leave your device.

Algorithm Variants

  • ChaCha20: A stream cipher (RFC 8439) that generates a keystream XORed with plaintext. Uses a 256-bit key and 96-bit nonce. Fast on devices without AES hardware acceleration.
  • ChaCha20-Poly1305 (AEAD): Combines ChaCha20 encryption with Poly1305 authentication. Provides both confidentiality and integrity — detects any tampering with the ciphertext. Recommended for most use cases.
  • XChaCha20: Extended-nonce variant with 192-bit nonce, safe for randomly generated nonces. Ideal when you cannot guarantee unique nonces through a counter.
  • XChaCha20-Poly1305: Extended-nonce AEAD construction. Combines the safety of random nonces with authenticated encryption.

Key and Nonce Requirements

  • Key: 128-bit (16 bytes) or 256-bit (32 bytes). Enter as String, Hex, or Base64. Use the Generate button for cryptographically secure random keys.
  • Nonce: A number used once. 96-bit (12 bytes) for ChaCha20, 192-bit (24 bytes) for XChaCha20. Never reuse the same nonce with the same key.
  • Counter: Initial block counter (usually 0). Must be the same for encryption and decryption.

ChaCha20 vs AES: When to Use Which

  • Choose ChaCha20: Better on mobile devices and CPUs without AES-NI instructions. Used in TLS 1.3, WireGuard VPN, and OpenSSH. Simpler design, resistant to timing attacks.
  • Choose AES-256: Hardware-accelerated on modern CPUs (AES-NI). Widely supported and the current industry standard. Required for compliance with certain regulations.
  • Both are secure: Choose based on your platform, performance requirements, and compatibility needs.

Frequently Asked Questions

What is ChaCha20 and how does it compare to AES?

ChaCha20 is a modern stream cipher designed by Daniel J. Bernstein in 2008. It is used in TLS 1.3, SSH, and VPN protocols (WireGuard). Compared to AES, ChaCha20 is faster on devices without AES hardware acceleration (phones, older CPUs) and is resistant to timing attacks. Both are considered secure, but ChaCha20 has a simpler design that is easier to implement correctly.

What is the difference between ChaCha20 and ChaCha20-Poly1305?

ChaCha20 is a stream cipher that provides confidentiality only. ChaCha20-Poly1305 is an AEAD (Authenticated Encryption with Associated Data) construction that combines ChaCha20 for encryption with Poly1305 for authentication. AEAD ensures both confidentiality and integrity — it detects any tampering with the ciphertext. Always prefer ChaCha20-Poly1305 unless you have a specific reason to use plain ChaCha20.

What is XChaCha20?

XChaCha20 is an extended-nonce variant of ChaCha20 that uses a 192-bit nonce instead of the standard 96-bit nonce. The larger nonce makes it safe to use with randomly generated nonces — the probability of a nonce collision is negligible even after billions of encryptions. XChaCha20 is ideal when you cannot guarantee unique nonces through a counter or sequence.

How do I generate a secure key for ChaCha20?

Use a cryptographically secure random number generator to create a 256-bit (32-byte) key, then encode it as hex (64 hex characters). Never reuse the same key with the same nonce — each encryption must use a unique nonce. For key derivation from a password, use PBKDF2, Argon2, or scrypt first, then use the derived key with ChaCha20.

Is my data sent anywhere?

No. All encryption and decryption happens locally in your browser using the @noble/ciphers library. Your key, nonce, and data never leave your device. This tool has no backend server — it is a pure client-side application.

What is the difference between Base64 and Hex output?

Both encode the same encrypted binary data as text. Base64 is more compact (33% smaller) and commonly used in emails and web applications. Hex uses only 0-9 and A-F characters, making it easier to read and paste into code or configuration files. Choose based on your use case.

What is the initial counter and when should I change it?

The counter is a 32-bit unsigned integer that sets the starting block number for the ChaCha20 keystream. In most cases, keep it at 0. The counter is useful when you need to encrypt multiple blocks of data separately but want them to form a continuous keystream. Both encryption and decryption must use the same counter value.

What is the swap button for?

The swap button (↔) quickly switches between encrypt and decrypt modes while swapping the input and output fields. This is useful when you want to verify your encryption by immediately decrypting it, or when you paste ciphertext and want to switch to decrypt mode without manually copying and pasting.

Privacy Note

This tool runs entirely in your browser. Your input is never uploaded, stored, or sent to any server.

Disclaimer: This tool is provided for educational and informational purposes only. The results do not constitute professional security advice. Use at your own discretion.

More in Encryption