Every time you open a WhatsApp message, stream a YouTube video, or connect to a VPN, billions of bytes of data are being encrypted in real time. The primitive doing most of that work is a stream cipher: a fast, elegant algorithm that takes a short secret key and stretches it into a long keystream â a river of pseudorandom bytes. Each plaintext byte is then XOR-ed with the next byte of the keystream to produce ciphertext.
The idea is beautiful in its simplicity. XOR is symmetric: C = P â K and P = C â K. The sender and receiver share the same key, generate the same keystream independently, and the ciphertext decrypts itself with one more XOR. No padding, no block boundaries â just a bitwise operation that a modern CPU can perform on 512 bits at once.
The most celebrated modern stream cipher is ChaCha20, designed by Daniel J. Bernstein in 2008. It replaced the aging and broken RC4 in TLS, SSH, and virtually every major protocol that needs speed without compromise. Salsa20, its predecessor, powers the NaCl cryptography library. These ciphers encrypt at multiple gigabytes per second â faster than your RAM can supply data.
But there is one rule that must never be broken: the same key and nonce pair must never be used twice. Violate it once and the encryption collapses entirely â not just for the repeated messages, but sometimes for everything protected by that key. The attack has a nickname: the two-time pad.
Comments
Loading comments...