ChaCha20-Poly1305 & Salsa20 Encrypt Online | Stream Cipher Browser

Encryption
100% client-side. Processed locally in your browser using the Web Crypto API. Nothing is sent to any server.
⚠️ Critical Security: Never reuse a nonce with the same key — XOR of two ciphertexts reveals both plaintexts instantly. Always use ChaCha20-Poly1305 (AEAD) for authenticated encryption. Use XChaCha20 variants when you need random nonce generation safety.

How It Works

What Is ChaCha20 / Salsa20?

ChaCha20 is a modern stream cipher designed by Daniel J. Bernstein as an improved variant of Salsa20. It provides high-speed encryption with excellent diffusion properties. ChaCha20-Poly1305 is an AEAD (Authenticated Encryption with Associated Data) construction that combines ChaCha20 for confidentiality with Poly1305 for authentication — detecting any tampering with the ciphertext.

This tool provides ChaCha20 and Salsa20 stream cipher encryption using the audited @noble/ciphers library. Choose between Passphrase mode (PBKDF2 key derivation with auto-generated salt and nonce) or Raw Key mode (direct key/nonce input in hex, Base64, or text). All cryptographic operations happen locally in your browser — your data never leaves your device.

When to Use ChaCha20

  • Modern encryption protocols — TLS 1.3, WireGuard VPN, and SSH all support ChaCha20-Poly1305
  • Mobile and IoT devices — ChaCha20 is software-optimized and faster than AES on devices without AES hardware acceleration
  • Authenticated encryption — Use ChaCha20-Poly1305 when you need both confidentiality and integrity
  • Random nonce scenarios — XChaCha20's 192-bit nonce makes random generation safe without counter management
  • Legacy system compatibility — Salsa20 for backward compatibility with older systems
  • When NOT to use — For block cipher requirements, use AES instead; ChaCha20 is a stream cipher

Algorithm Variants

VariantNonceAuthenticatedBest for
ChaCha2096-bit (12 bytes)NoRaw stream cipher, custom protocols
ChaCha20-Poly130596-bit (12 bytes)Yes (Poly1305 tag)General-purpose, TLS 1.3, WireGuard
XChaCha20192-bit (24 bytes)NoRandom nonce scenarios, no counter management
XChaCha20-Poly1305192-bit (24 bytes)Yes (Poly1305 tag)Authenticated encryption with random nonces
Salsa2064-bit (8 bytes)NoLegacy compatibility (predecessor to ChaCha20)

Standards Compliance

  • RFC 8439 — ChaCha20 and Poly1305 for IETF Protocols (2018)
  • TLS 1.3 — RFC 8446 (2018), mandates ChaCha20-Poly1305 as a cipher suite
  • WireGuard — Uses ChaCha20-Poly1305 for VPN encryption
  • NIST — ChaCha20 is not NIST-standardized but widely adopted as AES alternative

Last updated:

Code Examples

Encrypt with ChaCha20-Poly1305 using well-audited libraries:

JavaScript — @noble/ciphers (Browser)

import { chacha20poly1305 } from '@noble/ciphers/chacha';
import { randomBytes } from '@noble/ciphers/utils';

const key = randomBytes(32);   // 256-bit key
const nonce = randomBytes(12); // 96-bit nonce
const aad = new TextEncoder().encode('additional data');

const cipher = chacha20poly1305(key, nonce, aad);
const plaintext = new TextEncoder().encode('secret message');
const ciphertext = cipher.encrypt(plaintext);
console.log('Ciphertext:', Buffer.from(ciphertext).toString('base64'));

Python — PyCryptodome

from Crypto.Cipher import ChaCha20_Poly1305
import os

key = os.urandom(32)
nonce = os.urandom(12)
cipher = ChaCha20_Poly1305.new(key=key, nonce=nonce)

plaintext = b'secret message'
ciphertext, tag = cipher.encrypt_and_digest(plaintext)
print(f'Ciphertext: {ciphertext.hex()}')
print(f'Tag: {tag.hex()}')

Go — crypto/chacha20poly1305

package main

import (
    "crypto/rand"
    "fmt"
    "golang.org/x/crypto/chacha20poly1305"
)

func main() {
    key := make([]byte, chacha20poly1305.KeySize)
    rand.Read(key)
    
    aead, _ := chacha20poly1305.New(key)
    nonce := make([]byte, aead.NonceSize())
    rand.Read(nonce)
    
    plaintext := []byte("secret message")
    ciphertext := aead.Seal(nil, nonce, plaintext, nil)
    fmt.Printf("Ciphertext: %x\n", ciphertext)
}

Rust — chacha20poly1305 crate

use chacha20poly1305::{
    aead::{Aead, KeyInit, OsRng},
    ChaCha20Poly1305, Nonce,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let key = ChaCha20Poly1305::generate_key(&mut OsRng)?;
    let cipher = ChaCha20Poly1305::new(&key);
    let nonce = ChaCha20Poly1305::generate_nonce(&mut OsRng);
    
    let plaintext = b"secret message";
    let ciphertext = cipher.encrypt(&nonce, plaintext.as_ref())?;
    
    println!("Ciphertext: {:?}", ciphertext);
    Ok(())
}

Node.js — crypto module

const crypto = require('crypto');

const key = crypto.randomBytes(32);
const nonce = crypto.randomBytes(12);

const cipher = crypto.createCipheriv('chacha20-poly1305', key, nonce, {
    authTagLength: 16
});

const plaintext = 'secret message';
const ciphertext = Buffer.concat([
    cipher.update(plaintext, 'utf8'),
    cipher.final()
]);
const authTag = cipher.getAuthTag();

console.log('Ciphertext:', ciphertext.toString('base64'));
console.log('Auth tag:', authTag.toString('base64'));

Common Pitfalls & Attack Vectors

⚠️ Nonce Reuse with Same Key — Reusing a nonce with the same key completely breaks ChaCha20 security. An attacker can XOR two ciphertexts to recover both plaintexts instantly. Always use a unique nonce per key.
⚠️ Using Plain ChaCha20 Without Authentication — Plain ChaCha20 provides confidentiality only, not integrity. An attacker can flip bits in the ciphertext undetected. Always use ChaCha20-Poly1305 (AEAD) unless you have a specific reason to use plain ChaCha20.
⚠️ Insufficient Nonce Size for Random Generation — Standard ChaCha20's 96-bit nonce requires careful counter management when using random nonces. Use XChaCha20's 192-bit nonce for random generation safety.
⚠️ Using Salsa20 for New Projects — Salsa20 is the predecessor to ChaCha20 and has weaker diffusion properties. Use ChaCha20 or ChaCha20-Poly1305 for new projects; Salsa20 only for backward compatibility.
⚠️ Weak Key Derivation — If using passphrase mode, ensure PBKDF2 uses sufficient iterations (100,000+ recommended). The tool uses 100,000 iterations by default, but verify this meets your security requirements.

Security Notes

🔒 Never reuse a nonce with the same key — XOR of two ciphertexts reveals both plaintexts instantly.
🔒 Prefer Poly1305 variants — plain ChaCha20/Salsa20 provide no authentication; an attacker can flip bits in the ciphertext undetected.
🔒 XChaCha20 for random nonces — the 192-bit nonce makes random generation safe; standard ChaCha20's 96-bit nonce requires careful counter management.
🔒 Salsa20 is legacy — ChaCha20 was designed as an improved variant with better diffusion; use Salsa20 only for backward compatibility.

Disclaimer

Disclaimer: This page is for educational and testing purposes only. It does not constitute professional security advice. For production encryption systems, consult official standards (RFC 8439, NIST) and conduct a formal security review.

Further Reading & Standards

Related Concepts

Related Tools

Need block cipher encryption instead? Try AES Encrypt/Decrypt for NIST-standard security. For generating strong passphrases to use as encryption keys, the Passphrase Generator creates memorable, high-entropy phrases. To learn about XOR-based educational ciphers, try the XOR Encrypt/Decrypt tool.

Frequently Asked Questions

Which variant should I choose: ChaCha20, XChaCha20, or ChaCha20-Poly1305?

Use ChaCha20-Poly1305 for most cases — it provides authenticated encryption (AEAD) that detects tampering. Use plain ChaCha20 only when you need raw stream cipher output without authentication. Use XChaCha20 or XChaCha20-Poly1305 when you need a larger 192-bit nonce for random nonce generation safety.

What is the difference between ChaCha20 and ChaCha20-Poly1305?

ChaCha20 is a stream cipher that provides confidentiality only. ChaCha20-Poly1305 is an AEAD 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 Passphrase mode?

Passphrase mode derives a 256-bit encryption key from your passphrase using PBKDF2 (100,000 iterations, SHA-256). The salt and nonce are auto-generated for each encryption, so you only need to remember your passphrase. The output is Base64-encoded and includes the salt and nonce for decryption. This is ideal when you want to encrypt without managing raw keys and nonces manually.

What happens if I reuse a nonce with the same key?

Reusing a nonce with the same key completely breaks ChaCha20 security — an attacker can XOR two ciphertexts to recover both plaintexts. Always use a unique nonce per key. In Passphrase mode, nonces are randomly generated and embedded in the output, so this is handled automatically.

What nonce length do I need?

ChaCha20 and ChaCha20-Poly1305 require a 96-bit (12-byte) nonce. XChaCha20 and XChaCha20-Poly1305 require a 192-bit (24-byte) nonce. Salsa20 requires a 64-bit (8-byte) nonce. The tool validates nonce length automatically in Raw Key mode.

Privacy: This tool runs entirely in your browser — nothing is uploaded or stored. · Disclaimer: For educational purposes only. Not professional security advice.

More in Encryption

Learn More