Course contentsShow
← Computer Science
Lesson 2399 of 2,87254. Cryptography FundamentalsFree lesson

Block Ciphers vs Stream Ciphers

Compare encryption methods that process fixed-size blocks versus encrypting data bit-by-bit.

Block Ciphers vs Stream Ciphers

What you'll learn: How symmetric encryption algorithms differ when they process data in fixed-size chunks versus one bit (or byte) at a time.

In symmetric cryptography, we have two fundamental approaches to encrypting data: block ciphers and stream ciphers. The key difference lies in how they consume and transform your plaintext.

Block Ciphers: The Chunk Processors

A block cipher encrypts data in fixed-size blocks—typically 64, 128, or 256 bits at a time. Think of it like packing items into uniform shipping boxes: you must wait until you have enough items to fill a box before sealing and shipping it. If your last box isn't full, you add padding.

Each block is independently transformed using the secret key through multiple rounds of substitution and permutation operations (similar to the substitution and polyalphabetic techniques you've seen, but far more complex).

Analogy: Imagine translating a book by working on exactly one page at a time, applying the same complex transformation rules to each page before moving to the next.

Stream Ciphers: The Bit-by-Bit Encryptors

A stream cipher encrypts data one bit (or byte) at a time by generating a continuous keystream—a pseudorandom sequence of bits derived from your secret key. The plaintext is combined with this keystream (typically using XOR) as it flows through.

Analogy: Like a Vigenère cipher that never repeats its key pattern, stream ciphers generate an effectively infinite "key" that encrypts each character individually as you type.

When to Use Which

  • Block ciphers work well for stored data (files, databases) where you process complete chunks
  • Stream ciphers excel at real-time communication (streaming video, network packets) where data arrives continuously and buffering isn't practical

Key Takeaway: Block ciphers encrypt fixed-size chunks of data all at once, while stream ciphers encrypt data continuously bit-by-bit—choose based on whether your data naturally comes in discrete units or as a flowing stream.