Encrypt data with the ChaCha20 stream cipher
ChaCha20 is a high-speed ARX-based stream cipher designed by Daniel J. Bernstein, used in TLS and as a mobile-friendly alternative to AES.
- 1
ChaCha20 is a 256-bit key, 96-bit nonce stream cipher built from add-rotate-xor (ARX) operations. It needs no hardware acceleration to achieve high speed, making it ideal for mobile devices. We demonstrate the stream cipher workflow with RC4 (the legacy stream cipher) to illustrate the same operational pattern.
- 2 RC4 Encryptor →
Encrypt data with RC4 to see the stream cipher interface: provide a key and plaintext, receive ciphertext of the same length. ChaCha20 uses the same API but with a 96-bit nonce instead of RC4's stateful initialization.
- 3 RC4 Decryptor →
Decrypt with the same key to recover plaintext. Stream ciphers are symmetric: encryption and decryption use the same operation (XOR with the keystream).
- 4
Critical difference: RC4 is broken and must never be used in production. ChaCha20-Poly1305 (the authenticated variant) is the modern choice. The workflow above demonstrates the stream cipher API pattern, not RC4's security.
Frequently asked questions
- Why use ChaCha20 instead of AES?
- On devices without AES hardware acceleration (AES-NI), ChaCha20 is faster and constant-time by design, avoiding timing side-channels. It is the default in Google Chrome TLS on ARM Android.
- What is ChaCha20-Poly1305?
- It is the authenticated encryption combination of ChaCha20 (confidentiality) and Poly1305 (integrity). It is standardized as RFC 8439 and used in TLS 1.3. Never use ChaCha20 alone without authentication.
Workflows that solve this
Learn more
Want to understand why?