Skip to content

What encryption actually does

Keys, symmetric and public-key encryption, hashes, signatures, and what really happens when your browser opens an HTTPS page.

Part 01 of 09Beginner 7 min read
On this page

Every time you open a website, unlock your phone, pay with a card or push code to GitHub, cryptography does several different jobs at once. Before we talk about quantum computers it helps to know what those jobs are, because quantum computers threaten some of them badly and others barely at all.

This article covers the four building blocks: symmetric encryption, public-key cryptography, hashing and digital signatures, and then walks through an HTTPS connection step by step to show how they fit together.

The one idea underneath everything: keys

A cipher is a public recipe for scrambling data. The secret is not the recipe; it is the key, a random number fed into the recipe. This is Kerckhoffs's principle, and it is why we can publish algorithms like AES and let the whole world study them: the security rests entirely on the key staying secret and being too large to guess.

"Too large to guess" is measured in bits of security. A 128-bit key has 2^128 possible values, about 340 undecillion (3.4 × 10^38). If every computer on Earth tried a billion billion keys per second, it would still take far longer than the age of the universe to try them all. When cryptographers say an algorithm offers "128-bit security", they mean the best known attack costs about as much as trying 2^128 keys.

Keep that yardstick in mind: the whole quantum story is about which algorithms keep their bits of security and which lose them.

Symmetric encryption: one shared key

Symmetric encryption uses the same key to lock and unlock. Think of a padlocked box where you and a friend each hold a copy of the same key.

 plaintext ──► [ AES-256-GCM + key K ] ──► ciphertext ──► [ AES-256-GCM + key K ] ──► plaintext

The standard today is AES (the Advanced Encryption Standard, FIPS 197) with 128- or 256-bit keys, plus ChaCha20-Poly1305, which is popular on phones and in protocols like WireGuard. Symmetric ciphers are extremely fast (modern CPUs encrypt gigabytes per second) so they protect almost all actual data: your disk, your database backups, and the bulk of every HTTPS connection.

Two details matter in practice:

  • Use an authenticated mode. Modern modes such as GCM, or ChaCha20-Poly1305, detect tampering as well as hiding content. Old modes like ECB encrypt each block independently, so identical input blocks produce identical output and patterns leak through. A famous demonstration encrypts a picture of the Linux penguin in ECB mode and the penguin is still clearly visible.
  • Retired ciphers are still around. DES (56-bit keys) was brute-forced in the 1990s. Triple DES, Blowfish and RC4 have structural weaknesses. pqe's scanner flags these because they are weak today, quantum or not.

The hard part of symmetric encryption is not the maths. It is getting the shared key to the other person without anyone else seeing it. You cannot just email it.

Public-key cryptography: solving the key-sharing problem

In 1976, Whitfield Diffie and Martin Hellman published a way for two strangers to agree on a secret over a channel that everyone can listen to. A year later Rivest, Shamir and Adleman published RSA. This family is called public-key or asymmetric cryptography: each party has a key pair, a private key they never share and a public key they can hand to anyone.

A useful analogy is a mailbox with a slot. Anyone can drop a letter through the slot (that is the public key), but only the owner has the key that opens the box (the private key).

Public-key cryptography does two main jobs:

JobWhat it doesToday's algorithms
Key exchange (key agreement / key encapsulation)Two parties end up sharing a fresh secret that eavesdroppers can't computeECDH, X25519, Diffie-Hellman, RSA key transport
Digital signaturesProve who wrote something and that it hasn't changedRSA, ECDSA, Ed25519

Public-key operations are much slower than symmetric ones, so real systems use them only to set things up: agree on a symmetric key, or sign a small summary of the data. Then AES or ChaCha20 does the heavy lifting.

This is the part quantum computers break. Every public-key algorithm in wide use today (RSA, elliptic curves, Diffie-Hellman) rests on a maths problem that a large quantum computer could solve. The next article explains those problems; the one after explains the quantum attack.

Hashing: a fingerprint for data

A cryptographic hash function turns any input (a password, a file, a whole disk image) into a short, fixed-size fingerprint, such as 256 bits for SHA-256. Good hash functions have three properties:

  1. One-way: from the fingerprint you can't work back to the input (preimage resistance).
  2. Collision-resistant: you can't find two different inputs with the same fingerprint.
  3. Avalanche: change one bit of input and about half the output bits flip.

Hashes are everywhere: Git commit IDs, software download checksums, blockchain blocks, and inside signatures and key derivation. MD5 and SHA-1 are broken in the collision sense: researchers produce colliding files on demand, which has been used to forge certificates. SHA-256, SHA-384, SHA-512 and SHA-3 are fine, and, as we'll see, they stay fine against quantum computers.

Two close cousins of hashes:

  • HMAC combines a hash with a secret key to make a message authentication code. Webhook signatures and many API request signatures use HMAC-SHA-256. It is symmetric, so it shares symmetric cryptography's good quantum story.
  • Password hashes such as Argon2id, scrypt and bcrypt are deliberately slow and memory-hungry, so that someone who steals a password database can't try billions of guesses per second. Never store passwords with a plain fast hash like SHA-256, and certainly not MD5.

Digital signatures: proving who said what

A signature is created with a private key and checked with the matching public key. If even one bit of the signed data changes, verification fails. If someone without the private key tries to sign, verification fails.

 signer:    hash(message) ──► sign with PRIVATE key ──► signature
 verifier:  message + signature ──► verify with PUBLIC key ──► valid / invalid

Signatures protect software updates (your phone checks the vendor's signature before installing), Git commits and tags, legal documents, JSON Web Tokens, and the certificates that tell your browser it is really talking to your bank.

A certificate is a public key plus a name ("this key belongs to example.com"), signed by a certificate authority (CA) that your browser already trusts. The CA's own key is in turn vouched for by a root certificate shipped with your operating system or browser. That chain of signatures is how strangers on the internet trust each other.

Putting it together: what happens when you open an HTTPS page

Here is a simplified TLS 1.3 handshake, the protocol behind the padlock in your browser.

 Browser                                                Server
   │  1. ClientHello: supported ciphers + KEY SHARE  ──►  │
   │                                                       │
   │  ◄── 2. ServerHello: chosen cipher + KEY SHARE        │
   │       (both sides now compute the same secret)        │
   │  ◄── 3. Certificate (server's public key, signed by a CA)
   │  ◄── 4. CertificateVerify (server SIGNS the handshake) │
   │  ◄── 5. Finished                                      │
   │  6. Finished ──►                                      │
   │  ═══════ 7. Encrypted HTTP with AES-GCM / ChaCha20 ════│
  1. Your browser says hello and includes a key share: the public half of a fresh, one-time key-exchange key (on older browsers, typically X25519).
  2. The server replies with its own key share. Each side combines its private half with the other's public half and gets the same shared secret. An eavesdropper sees both public halves but can't compute the secret. That is the key-exchange job.
  3. The server sends its certificate, so your browser learns its long-term public key and checks the CA's signature on it.
  4. The server signs the handshake with its certificate's private key, proving it really owns that certificate, and that nobody in the middle swapped the key shares. That is the signature job.
  5. and 6. Both sides confirm they derived the same keys.
  6. Everything after that is symmetric encryption with keys derived from the shared secret, using AES-GCM or ChaCha20-Poly1305.

Notice which pieces carry long-term risk:

  • If an attacker records this conversation and can later solve the key-exchange maths, they recover the shared secret and decrypt everything in step 7, even years later. That is the "harvest now, decrypt later" problem, and it is why key exchange is the first thing to upgrade.
  • If an attacker can break the signature maths, they can impersonate servers, but only once they have that capability. Old recordings don't help them forge anything retroactively. That makes signatures important, but less urgent.
  • The symmetric encryption in step 7 is not the weak link.

You can see this in practice: modern browsers already send a hybrid post-quantum key share called X25519MLKEM768 in step 1. pqe's website checker (or npx -y pqe-cli check example.com) tells you whether a site accepts it.

Next: How public-key cryptography works: the maths problems behind RSA and elliptic curves, and why they are hard.