# Dissecting block and stream ciphers

Symmetric encryption algorithms are flexible, in that they can encrypt data using a block or stream cipher. In this section, we'll compare the two and see why, in most cases, a stream cipher is the preferred method to encrypt data.

Let's start with a discussion on how a block cipher works.

## Using a block cipher

A block cipher uses either a 64- or a 128-bit block of plaintext to produce a same-size block of ciphertext.

While this seems a simple way to encrypt data, we must keep in mind when using a block cipher that the block of data must be exactly the fixed-size requirement. Therefore, if encrypting data using a block size of 128 bits, the input must be 128 bits.

A block of data is rarely the exact size for a given encryption algorithm. As a result, if we need to encrypt 92 bits of data using a 128-bit block cipher, 32 bits of padding must be added. Too much padding during encryption will make the process inefficient...