# Block Cipher Vs Stream Cipher – the Difference Explained

Whether you’re using the internet for banking or sending a message on WhatsApp, encryption has a role to play everywhere. For example, whenever you enter your credentials on the web, they are shared across the internet in an encrypted form.

Ciphers are responsible for keeping your data safe, and they are of two types, Block Cipher and Stream Cipher. Now, what are they, and how are they different? Let’s read ahead and compare Block Cipher vs Stream Cipher.

Both of these Ciphers are a part of symmetric encryption. Symmetric encryption is a process where the same key is used to encrypt and decrypt the data. Some of the best examples of symmetric encryption are Blowfish, AES, DES, RC6, etc.

Here is how stream ciphers and block ciphers are used in symmetric encryption!

## Difference Between Block Cipher and Stream Cipher Explained

Before we jump into comparing block vs stream cipher, let’s analyze them individually!

## What is Block Ciphers?

As the name suggests, the block ciphers encrypt the data and return a fixed block size output. It means that no matter the input size, the resultant ciphertext will be of fixed block size.

The ciphertext size is usually in octaves (multiples of 8). However, it also depends on the encryption scheme used in the ciphering method.

### Here is Examples of Block Cipher

If you have a plain text of 148 bits, but the encryption scheme used is 128-bit encryption, the remaining 20 bits will be adjusted in the second block. As there will be space for 108 more bits, the encryption scheme will add padding of 0s or 1s or both to complete the ciphertext block.

**Now, as we know ciphertexts are of fixed blocks, and they are encrypted. But how?**

Block ciphers use symmetric keys and algorithms to encrypt sensitive data. As they can be used for various modes, the complexity of encryption can vary. For example, the blocks are chained together in some modes.

**Here is the process of how chained block ciphers work!**

In this process, a pseudorandom sequence of characters encrypts the first block of characters. This random sequence of characters is termed as Initialization Vector (IV). After obtaining the first block cipher, it is used as an IV for the next block. This process is followed for each block, and it thus produces a unique ciphertext each time.

The core benefit of a block cipher is that it is tamper-proof, which means that no one can crack it. The cipher has high diffusion because the IV used for each iteration is different and dependent on the previous block.

Though doubtful, changing one character can lead to a massive change in the cipher. Hence, the block cipher also has a higher error propagation rate.

### What are the Different Techniques of Block Ciphers Cryptography

Some of the best examples of block ciphers are:

- DES (Data Encryption Standard)
- AES (Advanced Encryption Standard)
- Twofish
- Blowfish
- RC5
- Triple-DES

### Modes of Operation for Block Ciphers

As we have teased the modes of block ciphers above, let’s explore them properly here! The modes of block ciphers are divided into two major categories.

### Confidentiality-only modes

There are three types under this!

**1. Electronic Codebook: **The ECB method splits the plaintext into various blocks. Each block is applied with encryption separately. As the pattern is not hidden in this case, it cannot be used in security frameworks.

**2. Cipher block chaining mode (CBC: **As explained above, the output ciphertext of one block is used as an initialization vector for the following block with plaintext input using the XOR function.

**3. Propagating cipher block chaining (PCBC): **This method involves XOR of current plaintext, previous plaintext, and previous ciphertext.

### Authenticated Encryption with Additional Data Operation Modes

There are two categories under this!

**1. Galois Counter mode: **An incremental counter generates a universal hash that generates message authentication codes before encryption and decryption.

**2. Synthetic initialization vector (SIV): **The SIV block cipher uses a plaintext input, an encryption key, and a header to achieve authenticated encryption. The header used is an authenticated variable-length octet string. SIV keeps the plaintext private while keeping the authenticity of the header and encryption key intact.

## What is Stream Ciphers?

Just like its name, the stream cipher encrypts the data in a continuous stream. Unlike block ciphers, bit-by-bit encryption happens in Stream ciphers. How?

### Stream Cipher Uses and Process

The input plaintext is not arranged in blocks before encryption but is directly encrypted bit by bit. The encryption process uses keystreams generated by combining an encryption key and a seed, called the nonce.

Combining the two produces a pseudorandom number, a keystream that is XORed (exclusive disjunction) with the plaintext to make the ciphertext.

The encryption key used here can be 128 or 256 bits, and nonce can be 64 or 128. The keystream used to produce ciphertext has to be unique, but the encryption key and nonce can be reused.

As it may seem tough, the process uses feedback shift registers that generate a unique seed or nonce every time. This nonce is only used one time to create the keystream.

The major benefit of stream ciphers is that they are less likely to experience system-wide propagation errors. How? As each bit is encrypted individually, it will not affect the ciphertext of the entire string, hence, fewer chances of errors.

Moreover, as stream ciphers happen continuously, they are faster and easy to implement.

Stream ciphers do not have diffusion as each bit is converted to ciphertext. Hence, hackers can easily break them. They can easily add or manipulate a message without being noticed.

Stream ciphers are ideal for scenarios with more plain text that cannot be determined.

Some of **the best examples of Stream Ciphers** are

- A5
- ChaCha40
- Salsa20
- RC4

### Stream Ciphers Examples

The stream ciphers are primarily of two types!

**1. Synchronous Stream Ciphers: **These types of ciphertexts are generated without the use of keystreams that are not generated using previous ciphertexts or plaintexts. A unique pseudorandom number is used to make the keystream for each ciphertext. This keystream is further XORed with the plaintext to generate the ciphertext.

**2. Asynchronous Stream Ciphers: **In this cipher, the keystream is generated using the synchronous key and fixed size of the previous ciphertext. As the contents of the ciphertext are affected, the respective keystream is also affected. This cipher can detect active attacks and further limit error propagation.

## Differentiate Stream Cipher and Block Cipher using a suitable example. – How Do They Vary?

The block cipher vs stream cipher comparison is easy to make as we know what they are! So, let’s get started! Here is a quick tabular comparison of both the ciphers!

Block Cipher | Stream Cipher |

It requires a block of data at a time for ciphering. | The stream cipher converts 1 byte of data at a time into ciphers. |

Block cipher is less complex. | The complexity of stream cipher is more. |

Block cipher offers better data security | Block cipher offers better data security. |

Reversibility is slow | Reversibility is faster |

The need for resources is high | Resources required by stream cipher are less |

### Conversion

One of the prime and visible differences between block vs stream cipher is bit conversion. How? Well, the block conversion method requires the plaintext block to be accumulated first and then converted to ciphertext. On the other hand, the stream cipher converts quickly as plaintext is encrypted one bit at a time. Thus, making it continuous and fast.

As the devices today are fast, the time difference may not be that significant.

### Security

If we compare the ciphers based on security, the strength of the key determines the power of a cipher. However, out of both of these ciphers, block ciphers can be used to provide authenticated encryption, not stream cipher. So, a block cipher is better. Stream cipher only uses the confusion principle to encrypt data, so it is better only in terms of maintaining confidentiality.

### Reversibility

Obviously, if the ciphering takes more time to encrypt, the decryption time will also be more. Stream-based encryption can be easily reversed by XORing their outputs. But, in the case of block cipher, more bits are encrypted. Hence, the reversibility, in this case, is slow.

### Resources

This is where the stream ciphers outshine the block ciphers. As block ciphers require complex calculations as compared to stream ciphers, they require relatively more resources.

### Redundancy

Redundancy is one of the critical factors. If the block cipher does not find exact octaves in the input plaintext, padding bits are added to complete the block. Though it is necessary to produce the ciphertext, it also increases the redundancy of plain text.

However, stream ciphers do not have any redundancies as it encrypts bit by bit.

### Application area

As block cipher provides authenticated encryption, it is best for almost any application where encryption is necessary. In contrast, the stream cipher is used only for applications like data-in-transit encryption.

So, that’s all about Block Cipher Vs Stream Cipher.

## Wrapping Up!

So, we know that encryption is the wall that stands between your sensitive data and the hackers. The block and stream ciphers are the warriors who take care of this wall. Block ciphers are powerful but slow in terms of security. On the other hand, stream ciphers have a limited scope of application but are faster than block ciphers.

We hope this article was fruitful and you enjoyed reading it!