Interactive Visualization

Stream Cipher

Bit-by-bit XOR in action — watch plaintext combine with a keystream to produce ciphertext one bit at a time.

Plaintext Keystream Ciphertext XOR Node
Plaintext
Keystream
Ciphertext

How stream ciphers work

A stream cipher encrypts data one bit (or byte) at a time by XOR-ing each plaintext unit with a corresponding unit from a pseudo-random keystream. The keystream is generated from a secret key and (typically) an initialization vector.

The XOR operation is reversible: applying the same keystream to the ciphertext recovers the original plaintext. This makes stream ciphers fast and well-suited for real-time communication like TLS, Wi-Fi (RC4/WEP, now deprecated), and modern constructions like ChaCha20.

Unlike block ciphers that process fixed-size chunks, stream ciphers have no block boundary — they produce output continuously as data arrives. The visualization above shows this bit-by-bit flow: each plaintext bit enters from the left, meets the keystream at the XOR node, and the resulting ciphertext bit exits to the right.