A cipher is a set of mathematical rules, or algorithm, used to convert readable text, or plaintext, into unreadable text, or ciphertext. The principle difference between stream ciphers and block ciphers is that stream ciphers work on streams of text, one bit or one byte at a time, while block ciphers work on blocks of text.

## Stream Cipher

The basic idea of a stream cipher is to divide text into small blocks, one bit or one byte long, and encode each block depending on many previous blocks. Stream ciphers use a different encryption key -- a value which must be fed into the algorithm -- for each bit or byte, so the same bit or byte produces different ciphertext each time it is encrypted. Some stream ciphers use a keystream generator, which produces a random, or nearly random, stream of bits. The cipher performs a Boolean operation, known as an exclusive OR, between the bits in the keystream and the bits in the plaintext to produce ciphertext.

## Video of the Day

## Block Cipher

The basic idea of a block cipher is to divide text in relatively large blocks, typically 64 or 128 bits long, and encode each block separately. The same encryption key is used for each block and it is the encryption key that determines the order in which substitution, transportation and other mathematical functions are performed on each block. Strong algorithms mean that reverse engineering the cipher, or determining which functions were performed on each block, in which order, virtually impossible.

## Diffusion and Confusion

Block ciphers use techniques known as confusion and diffusion to encrypt plaintext into ciphertext. The idea behind confusion is to make the relationship between the encryption key and the ciphertext as complex as possible. Ideally, every character in the encryption key should influence every character in the ciphertext. By contrast, diffusion spreads the influence of each character in the plaintext over several characters in the ciphertext, making the cipher less susceptible to statistical attacks.

## Pros and Cons

The fact that stream ciphers encrypt and decrypt data one bit at a time means that they are particularly well-suited to real-time hardware applications, such as audio and video applications. Stream ciphers are weaker and less efficient than block ciphers when it comes to software applications and are less frequently used in that sphere. Block ciphers are easier to implement in software because they encrypt data in blocks of a length that software already uses. The encryption key is often the same length as the block size.