Free — no signup required

Symmetric Encryption: The Shared Secret

3 min read

The "Door Key" Analogy

Symmetric encryption is the simplest form of encryption to understand conceptually. It uses a single, shared secret key to both encrypt and decrypt data. The same key that locks the data is the key that unlocks it.

Think of it like the key to your front door. You use the key to lock the door when you leave, and you use the exact same key to unlock it when you return. If you want to give a trusted friend access to your home, you make a copy of that key and hand it to them in person. The security of your home depends entirely on keeping that key out of the wrong hands.

How It Works in Practice

The industry-standard symmetric algorithm is AES (Advanced Encryption Standard), standardized by NIST in 2001. AES operates on fixed-size blocks of data (128 bits at a time) and supports key sizes of 128, 192, or 256 bits. AES-256 is the gold standard for high-security applications.

AES is used in several modes of operation that determine how it handles data larger than one block:

  • AES-CBC (Cipher Block Chaining): Each block of plaintext is XOR'd with the previous ciphertext block before encryption. Requires an Initialization Vector (IV) — a random value used for the first block to ensure identical plaintexts produce different ciphertexts. Widely used but requires careful IV management.
  • AES-GCM (Galois/Counter Mode): The modern preferred mode. Provides both encryption (confidentiality) and authentication (integrity) in a single operation — this property is called Authenticated Encryption with Associated Data (AEAD). If the ciphertext is tampered with, decryption will fail and raise an error. AES-GCM is used in TLS 1.3 and is the recommended default for new systems.

Pros and Cons

  • Pro — Speed: Symmetric algorithms are extremely fast. Modern CPUs include hardware-level AES acceleration instructions (AES-NI), making AES-GCM capable of encrypting data at multi-gigabyte-per-second speeds. This makes it ideal for bulk data encryption.
  • Con — Key Distribution Problem: The fundamental challenge is safely sharing the key. If Alice wants to send Bob an encrypted message, she needs to first get the secret key to Bob. But if she sends the key over the internet, an attacker could intercept it. How do you securely share a secret with someone you've never met? This is the key distribution problem, and it's why symmetric encryption alone is insufficient for open internet communication.
Interview Tip

Interviewers frequently ask: "Why don't we just use AES for everything?" The correct answer addresses the key distribution problem: symmetric encryption requires a pre-shared secret, which is impossible to establish securely with a stranger over an untrusted network without a separate mechanism. This is precisely why TLS uses asymmetric encryption to establish a shared symmetric key — combining the security of asymmetric with the speed of symmetric. This hybrid approach is called a Key Encapsulation Mechanism (KEM).

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free