Explain the difference between a stream cipher and a block cipher.

Stream Cipher:

A stream cipher is a type of symmetric-key encryption algorithm that operates on a continuous stream of data. It encrypts or decrypts data one bit or byte at a time, in a continuous fashion. The basic idea is to generate a pseudorandom key stream, often called a keystream, which is combined with the plaintext using bitwise XOR (exclusive OR) operation.

Key Points:

  1. Keystream Generation:
    • A key stream generator produces a stream of pseudorandom bits based on a secret key.
    • The keystream is combined with the plaintext using XOR, and the same operation is performed in reverse during decryption.
  2. Synchronization:
    • Synchronization is crucial in stream ciphers. Both the sender and the receiver must be synchronized in terms of the initial state of the keystream generator.
  3. Efficiency:
    • Stream ciphers are often more efficient for real-time applications and situations where the data is continuously flowing.
  4. Example:
    • A well-known stream cipher is the "RC4" algorithm, which was widely used in protocols like SSL and WEP.

Block Cipher:

A block cipher, on the other hand, processes fixed-size blocks of data at a time. The plaintext is divided into fixed-size blocks, and each block is independently encrypted. The same key is used for each block, and the operation is reversible, allowing decryption.

Key Points:

  1. Fixed Block Size:
    • Block ciphers operate on fixed-size blocks of data, typically 64 or 128 bits in size.
  2. Block Independence:
    • Each block is treated independently during encryption and decryption. The same key is applied to each block, but the result depends on both the key and the specific block being processed.
  3. Modes of Operation:
    • Block ciphers are often used in various modes to handle different types of input, such as Electronic Codebook (ECB), Cipher Block Chaining (CBC), etc.
  4. Padding:
    • Since the input might not always be an exact multiple of the block size, padding schemes are often employed to fill the last block.
  5. Examples:
    • The Advanced Encryption Standard (AES) is a widely used block cipher. It operates on 128-bit blocks.


  • Processing:
    • Stream ciphers process data continuously bit by bit.
    • Block ciphers process fixed-size blocks of data.
  • Synchronization:
    • Stream ciphers require synchronization between sender and receiver for proper decryption.
    • Block ciphers operate independently on each block.
  • Efficiency:
    • Stream ciphers are often more efficient for continuous data streams.
    • Block ciphers are versatile and used in various modes for different applications.