Stream Ciphers vs. Block Ciphers

Symmetric ciphers are divided into two types: stream ciphers and block ciphers.

Stream ciphers are a pair of encryption and decryption algorithms that encrypt/decrypt every bit (or byte) separately. That is, the result of the encryption of one bit won't affect the manner in which the next bit is encrypted.

This type of a cipher is most suitable for the encryption of plaintext that is generated 'on the fly', such as media streams.

Stream ciphers work as follows:

  1. A random-like (= pseudo-random) string of bits is generated. This sequence of bits will be our encryption key.
  2. Each bit of the plaintext is XORed with a bit from the key.

Notation: for (i = 0, i < n, i++) ciphertext[i] = plaintext[i] ⊕ key[i];