Learn the difference between Block Cipher and Stream Cipher. The basis of comparison include: Description, Key Use, Integrity, XOR Function, Plaintext Encryption, Speed, Implementation and Algorithm modes.

## What is a Cipher?

A cipher is a method of hiding words or text with encryption by replacing original letters with other letters, numbers and symbols through either substitution or transposition. A cipher often enables private communication and is often used in email, so that if an encrypted message is intercepted by an unauthorized user, the message cannot be read.

There are a number of cipher types, however two typical examples are:

- Baconian: This hides a message inside another message with various fonts, typefaces or characteristics.
- Atbash: The letter A is changed to a Z. B is changed to a Y, D is changed to Q, E is changed to W, F is changed to P and so on.

## Stream Cipher

A stream cipher is a symmetric key cipher (method of encryption) where plaintext digits are combined with a pseudorandom cipher digit stream. A stream cipher encrypts plaintext with a key and algorithm applied to every binary digit (one and zeros) for every bit in the data stream. The pseudorandom cipher digits are generated through a number of random seed values that use digit shift registers.

In a stream cipher, text is divided into small blocks, one bit or one byte long and each block is encoded depending on many previous blocks.

### Types of Stream Cipher

**Synchronous Stream Ciphers**: A synchronous stream cipher generates a Keystream based on internal states not related to the plaintext or ciphertext. Encryption and decryption require that the synchronous state cipher be in the same state, otherwise the message cannot be decrypted.**Self-Synchronising Stream Ciphers:**A self-synchronizing Stream Cipher, also known as an asynchronous stream cipher or ciphertext autokey (CTAK), is a stream Cipher which uses the previous*N*digits in order to compute the keystream used for the next*N*characters.

## Block Cipher

A block cipher is an encryption method that applies a deterministic algorithm along with a symmetric key to encrypt a block of text, rather than encrypting one bit at a time as in stream ciphers. In block cipher, text is divided in relatively large blocks, typically 64 0r 128 bytes long and that each block is encoded separately. Plaintext is used during the encryption and the resulting encrypted text is referred to as a ciphertext.

Block cipher algorithm is symmetric in that, during encryption, it uses the shared key to transform its plaintext input into a cyphertext (encrypted text). During decryption, it uses the same key to transform the ciphertext back to the original plaintext. The length of the output is the same as the input.

## Key Difference

- A stream cipher is a symmetric key cipher (method of encryption) where plaintext digits are combined with a pseudorandom cipher digit stream. On the other hand, a block cipher is an encryption method that applies a deterministic algorithm along with a symmetric key to encrypt a block of text.
- Stream cipher uses a different key for each byte whereas; block cipher uses the same key to encrypt each block.
- Stream cipher uses XOR function for converting the plain text into cipher text that is the reason why it is easy to reverse the XORed bits. In contrast, block cipher do not use XOR function.
- Stream cipher uses confusion to encrypt plaint text whereas block ciphers use both confusion and diffusion to encrypt plaintext into ciphertext.
- 1 byte (8 bits) at a time is converted in the stream cipher, this makes the process faster whereas, in block ciphers, the normal size of the block could be 64 or 128 bits in the block cipher and this makes block cipher slower than stream cipher.
- Stream cipher uses CFB (Cipher Feedback) and OFB (Output Feedback) algorithm modes. On the other hand, block cipher uses ECB (Electronic Code Book) and CBC (Cipher Block Chaining) algorithm modes.
- Stream Ciphers does not require large memory because they only work on small bits at a time unlike block ciphers that require a relatively large memory because they work on a large chunk of data.
- Stream ciphers do not provide integrity protection or authentication. On the contrary, some block ciphers (depending on the mode) can provide integrity protection, in addition to confidentiality.
- Stream ciphers are more difficult to implement correctly, and are prone to weaknesses based on usage. On the contrary, block ciphers are relatively easy to implement.

**Also Read: ***Difference Between Monoalphabetic And Polyalphabetic Cipher*

## Difference Between Block Cipher And Stream Cipher In Tabular Form

BASIS OF COMPARISON | STREAM CIPHER | BLOCK CIPHER |

Description | A stream cipher is a symmetric key cipher (method of encryption) where plaintext digits are combined with a pseudorandom cipher digit stream. | A block cipher is an encryption method that applies a deterministic algorithm along with a symmetric key to encrypt a block of text. |

Key Use | Stream Cipher uses a different key for each byte. | Block cipher uses the same key to encrypt each block. |

Integrity | Stream ciphers do not provide integrity protection or authentication. | Some block ciphers (depending on the mode) can provide integrity protection, in addition to confidentiality. |

XOR Function | Stream cipher uses XOR function for converting the plain text into cipher text that is the reason why it is easy to reverse the XORed bits. | Block cipher do not use XOR function. |

Plaintext Encryption | Stream cipher uses confusion to encrypt plaint text. | Block ciphers use both confusion and diffusion to encrypt plaintext into ciphertext. |

Speed | 1 byte (8 bits) at a time is converted in the stream cipher, this makes the process faster. | Block ciphers, the normal size of the block could be 64 or 128 bits in the block cipher and this makes block cipher slower than stream cipher. |

Implementation | Stream ciphers are more difficult to implement correctly, and are prone to weaknesses based on usage. | Relatively easy to implement. |

Algorithm Modes | Stream cipher uses CFB (Cipher Feedback) and OFB (Output Feedback). | Block cipher uses ECB (Electronic Code Book) and CBC (Cipher Block Chaining). |

**Also Read**: *Difference Between Linear And Differential Cryptanalysis*

### Advantages of Stream Cipher Over Block Cipher

- Stream ciphers are typically faster than block ciphers and work well for large or small chunks of data.
- Stream Ciphers does not require large memory because they only work on small bits at a time unlike block ciphers that require a relatively large memory because they work on a large chunk of data.
- Stream cipher bytes are individually encrypted with no connection to other chunks of data whereas block ciphers encrypt a whole block at a time.
- Stream ciphers are usually best for cases where the amount of data is either unknown or continuous such as network streams while block ciphers are more useful when the amount or length of data is known such as file, data fields or response protocol.