Stream Cipher · ARX · RFC 8439
Encrypt and decrypt with ChaCha20 while watching the ARX quarter-round build a keystream, then XOR it against your message — and see a reused nonce collapse into a two-time pad.
A stream cipher turns a secret key plus a
one-time nonce into a long, random-looking
keystream, then XORs that keystream with your
message to encrypt it. Decryption is the same XOR again, because
x ⊕ y ⊕ y = x. The whole cipher rests on one equation you'll see
live below:
ciphertext = plaintext ⊕ keystream
The rule in one line: the nonce must never repeat under the same key. Section 4 shows what an attacker does the moment it does.
Here is the whole cipher, one byte per column: your
plaintext XOR the
keystream gives the
ciphertext. Hover or focus a column to
trace one byte through ct = pt ⊕ ks.
Same key, different nonce → completely different keystream
Colour encodes byte value only (low = blue, high = red) so the grid is easy to scan — it carries no cryptographic meaning. The real "is it random?" signal is the avalanche stat below, not any pattern in the hues.
Watch the 4×4 state matrix evolve through all 80 quarter-rounds. The four highlighted cells are the words being mixed by the current quarter-round.
Press Initialize Block to build the state matrix from the current key & nonce.
The keystream is gone, so an attacker who guesses one message instantly recovers the other — no key required. The guess is pre-filled with the real Message 1; edit it and watch the recovery degrade character-by-character.
ChaCha20 uses only three operations — Add (mod 2³²), Rotate (bit rotation), and XOR. These are constant-time on virtually all CPUs, making side-channel attacks fundamentally harder.
ChaCha20 operates on a 4×4 matrix of 32-bit words (512 bits total):
| cccccccc | cccccccc | cccccccc | cccccccc |
| kkkkkkkk | kkkkkkkk | kkkkkkkk | kkkkkkkk |
| kkkkkkkk | kkkkkkkk | kkkkkkkk | kkkkkkkk |
| bbbbbbbb | nnnnnnnn | nnnnnnnn | nnnnnnnn |
0x61707865 0x3320646e 0x79622d32 0x6b206574)AES requires dedicated hardware instructions (AES-NI) to run safely and quickly. On devices without AES-NI — most ARM chips before 2011, many IoT devices, some embedded systems — AES implementations leak timing information that can expose keys. ChaCha20 is immune to this entire class of attack by design. That's why TLS 1.3 supports it as a first-class cipher suite.