keystream

A stream of random-looking bytes made from a key and a nonce, which a stream cipher combines with the message using XOR to encrypt it.

In more detail

Decryption makes the same keystream and applies XOR again, which restores the plaintext. The keystream must never repeat: if two messages share it, combining their ciphertexts removes it and exposes the messages. Counter mode, GCM and ChaCha20 all work this way.

Example

keystream = bytes(c ^ p for c, p in zip(c1, known))

Related terms

Taught in

References