Skip to main content

Computer Science · Encryption Unit · Session 3 of 8

The trick that lets two strangers agree on a secret, in full view of everyone.

Symmetric encryption left us with a problem: both sides need the same key, but how do you safely hand someone a key across a network you don't trust? Public-key encryption solves it — and it's the reason a padlock appears in your browser every time you visit your bank.

A padlock icon on a laptop keyboard, surrounded by swirling light trails.
Photo: FlyD / Unsplash

Executive summary

Goal: explain how public/private key pairs work, solve the key exchange problem, and explain what HTTPS is and why it matters.

TimeSegment
0–10 minDiagnostic: the stranger problem
10–30 minExplaining public and private keys
30–45 minWorked example: HTTPS in your browser
45–55 minActivity: HTTPS vs HTTP
55–60 minExit question and key terms

Before you start​

Two keys, not one​

Public-key encryption (also called asymmetric encryption) gives every user a mathematically linked pair of keys instead of one shared key:

  • A public key, which can be freely shared with anyone — published, emailed, put on a website. It only encrypts.
  • A private key, which is kept completely secret and never shared. It only decrypts what was encrypted with its matching public key.

This directly solves the problem Session 2 ended on. Anyone can encrypt a message using your public key — you can hand it out to the whole internet with no risk — but only you, holding the matching private key, can ever decrypt it. There's no need to secretly exchange anything beforehand, because the key that gets shared openly is only ever useful for locking, never for unlocking.

HTTPS: public-key encryption, running in your browser right now​

HTTP (HyperText Transfer Protocol) sends data between your browser and a website in plain, readable text. HTTPS ("HTTP Secure") adds an encryption layer — built using public-key encryption — so that traffic between you and the site is unreadable to anyone intercepting it along the way.

You can see this happening every day: Google's Chrome browser, along with every other modern browser, marks HTTPS sites with a padlock icon and actively warns you before you enter data on a plain HTTP site. Since the mid-2020s, the overwhelming majority of web traffic — including virtually every bank, every school portal, and every online retailer such as Amazon — uses HTTPS by default.

Activity: HTTPS vs HTTP​

For each situation, explain what could go wrong if the connection were plain HTTP instead of HTTPS.

  1. Logging into your school's student portal from the school's shared Wi-Fi.
  2. Typing your card details into an online shop's checkout page.
  3. Searching a symptom on a health information website.
Reveal model answers and check your work
  1. Anyone else on the same Wi-Fi network could potentially intercept and read your username and password as plain text.
  2. Your card number, expiry date, and security code would be sent as readable plaintext, visible to anyone intercepting traffic between you and the shop's server.
  3. Your search terms — potentially sensitive health information — would be visible to anyone on the network path, even though you never explicitly "sent" them to a third party.

Exit question​

Explain how public-key encryption solves the key exchange problem that symmetric encryption alone cannot, and describe one real consequence of a website using HTTP instead of HTTPS.

Key terms

  • public-key encryption
  • asymmetric encryption
  • public key
  • private key
  • HTTPS
  • digital certificate
  • certificate authority
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8