🔐 Encryption Modes Explorer

Interactive guide to block cipher modes of operation

Triple DES (3DES)

Triple DES applies the DES algorithm three times to each data block, using either two or three different keys. This significantly increases security compared to single DES.

Plain Text
→
Key 1
Encrypt
→
Key 2
Decrypt
→
Key 3
Encrypt
→
Cipher Text

3DES Variants

DES-EDE3

Three independent keys

Encrypt → Decrypt → Encrypt

DES-EDE2

Two keys (K1 = K3)

More common variant

Security Level

112-bit effective key length

Much stronger than DES

Advantages

  • Backward compatible with DES
  • Widely supported
  • Well-tested algorithm
  • Significantly more secure than DES

Disadvantages

  • Slower than AES
  • Small block size (64 bits)
  • Being phased out
  • Vulnerable to certain attacks

Electronic Code Book (ECB)

ECB is the simplest mode where each block is encrypted independently using the same key. Identical plaintext blocks produce identical ciphertext blocks.

Block 1
→
Key
→
Cipher 1
Block 2
→
Key
→
Cipher 2

ECB Demonstration

Advantages

  • Simple to implement
  • Parallel processing possible
  • No error propagation
  • Random access to blocks

Disadvantages

  • Reveals patterns in data
  • Identical blocks = identical ciphertext
  • Not secure for most applications
  • Vulnerable to replay attacks

Cipher Block Chaining (CBC)

CBC mode chains blocks together by XORing each plaintext block with the previous ciphertext block before encryption. The first block uses an Initialization Vector (IV).

IV
⊕
Block 1
→
Key
→
Cipher 1
Cipher 1
⊕
Block 2
→
Key
→
Cipher 2

CBC Simulation

Advantages

  • Hides patterns in plaintext
  • Each block depends on previous
  • Widely used and trusted
  • Good for most applications

Disadvantages

  • Sequential processing required
  • Error propagation
  • Requires padding
  • IV must be unpredictable

Cipher Feedback (CFB)

CFB mode turns a block cipher into a stream cipher. The cipher encrypts the previous ciphertext block (or IV), and the result is XORed with the plaintext.

IV
→
Key
→
Keystream
⊕
Block 1
→
Cipher 1
Cipher 1
→
Key
→
Keystream
⊕
Block 2
→
Cipher 2

CFB Characteristics

Stream Cipher

Processes data bit by bit or byte by byte

Self-Synchronizing

Errors don't propagate indefinitely

Real-time

Suitable for real-time applications

Advantages

  • No padding required
  • Stream cipher properties
  • Self-synchronizing
  • Real-time processing

Disadvantages

  • Sequential processing
  • Error propagation (limited)
  • More complex than ECB
  • Requires careful IV management

Output Feedback (OFB)

OFB mode creates a keystream by repeatedly encrypting the IV and previous outputs. This keystream is XORed with the plaintext to produce ciphertext.

IV
→
Key
→
Output 1
⊕
Block 1
→
Cipher 1
Output 1
→
Key
→
Output 2
⊕
Block 2
→
Cipher 2

OFB Key Features

Keystream Generation

Independent of plaintext

No Error Propagation

Bit errors don't spread

Synchronous

Requires synchronized encryption/decryption

Advantages

  • No error propagation
  • Keystream can be pre-computed
  • No padding required
  • Suitable for noisy channels

Disadvantages

  • Synchronization required
  • Keystream reuse is dangerous
  • Sequential processing
  • Loss of sync is catastrophic

Counter (CTR)

CTR mode encrypts a counter value to generate a keystream. The counter is incremented for each block, and the resulting keystream is XORed with the plaintext.

Nonce (Counter)
→
Key
→
Keystream
⊕
Block 1
→
Cipher 1
Nonce + 1
→
Key
→
Keystream
⊕
Block 2
→
Cipher 2
Nonce + 2
→
Key
→
Keystream
⊕
Block 3
→
Cipher 3

CTR Mode Benefits

Parallel Processing

Blocks can be processed independently

Random Access

Can decrypt any block without previous blocks

No Padding

Works with any data length

Stream Cipher

Provides stream cipher properties

Advantages

  • Parallel processing
  • Random access to blocks
  • No padding required
  • High performance

Disadvantages

  • Counter values must not repeat
  • Requires careful nonce management
  • Vulnerable to bit-flipping attacks
  • No built-in authentication

Mode Comparison

ECB

Security: ⭐⭐

Performance: ⭐⭐⭐⭐⭐

Parallelization: ⭐⭐⭐⭐⭐

Error Propagation: None

Use Case: Random data only

CBC

Security: ⭐⭐⭐⭐

Performance: ⭐⭐⭐

Parallelization: ⭐⭐

Error Propagation: Limited

Use Case: File encryption

CFB

Security: ⭐⭐⭐⭐

Performance: ⭐⭐⭐

Parallelization: ⭐⭐

Error Propagation: Limited

Use Case: Real-time data

OFB

Security: ⭐⭐⭐⭐

Performance: ⭐⭐⭐

Parallelization: ⭐⭐

Error Propagation: None

Use Case: Noisy channels

CTR

Security: ⭐⭐⭐⭐

Performance: ⭐⭐⭐⭐⭐

Parallelization: ⭐⭐⭐⭐⭐

Error Propagation: None

Use Case: High-speed encryption

Security Comparison Table

Mode Padding Required IV/Nonce Parallel Decrypt Random Access
ECB ✅ ❌ ✅ ✅
CBC ✅ ✅ ✅ ❌
CFB ❌ ✅ ❌ ❌
OFB ❌ ✅ ❌ ❌
CTR ❌ ✅ ✅ ✅

When to Use Each Mode

🚫 Never Use ECB

For any real data - patterns will be visible

📁 Use CBC for Files

Traditional choice for file encryption and Message Authentication

🔄 Use CFB for Streams

Real-time data, network protocols

📡 Use OFB for Noisy Data

Satellite communications, error-prone channels

⚡ Use CTR for Performance

High-speed encryption, disk encryption