This blog will introduce the first type of the **symmetric cipher**, which is known as “**Stream Ciphers**“.

The figure below shows the encryption and decryption process in stream ciphers:

__Note:____ Plaintext = ____x _{i}__

__, Ciphertext =__

__y___{i}__& key stream =__

__s___{i}__.__

Encryption and decryption are same functions, where they are simple additions modulo 2 (XOR).

Encryption: |
y_{i} = e_{si}(x_{i}) = x_{i} + s_{i} mod 2 |

Decryption: |
x_{i} = d_{si}(y_{i}) = y_{i} + s_{i} mod 2 |

__Note:____ x_{i} , y_{i} & s_{i} __

__∈ {0,1}.__

The question is – What is the difference between the **key (k)** and the **key stream (s)? **The key is used to encrypt and decrypt the message and it is only known only by the sender and the receiver. The key stream, on the other hand, is the result of the XORed key and generated from the original key. Usually, the original key goes through a process called “**key stream generator**” to generate the key stream.

Before we get deep into the process of key stream generator, let’s have a look at the of XOR operation. **XOR operation** is equivalent to **modulo 2 addition**. This is good for perfectly random key stream (*s _{i}*), where each ciphertext output bit has a chance of

**to be either (**

__50%__**). Also, inverting the XOR is simple, since it is the same XOR operation.**

__0 or 1__

The figure below shows the process of generating the **key stream**.

The security of stream cipher depends entirely on the key stream (*s _{i}*), where it should be:

- Should be
.__random__ - Must be
by sender and receiver.__reproducible__

Stream ciphers can be either **Synchronous Stream Cipher** or **Asynchronous Stream Cipher**. The difference is that the Synchronous Stream Cipher the **key stream** (*s _{i}*) depends only on the

**key**(

*k*). However, Asynchronous Stream Cipher the

**key stream**(

*s*) depends on both the

_{i}**key**(

*k*) and the

**ciphertext**.