How does HTTPS keep websites secure?
You add your secret to the site's public mix; the site adds its secret to yours. Both end up with public + yours + site's. The eavesdropper only saw the two half-mixes: combining them gives a colour with too much public paint in it, and she can't un-mix them to get either secret.
Overview
Short answer
HTTPS encrypts everything between your browser and a website. The two sides agree on a secret key in public using key exchange, which an eavesdropper can’t reverse, and the site proves its identity with a certificate signed by an authority your browser trusts.
The padlock next to a website address means your connection uses HTTPS: everything between your browser and the site is encrypted, so people on the same WiFi, your internet provider or anyone along the way see only scrambled data. The hard part is agreeing on a secret key with a computer you have never met, over a connection anyone can watch.
Play with the figure, then press Next (or the → key) to go step by step.
Agreeing a secret in public
The answer is key exchange, often explained with paint. Each side mixes a secret colour into a shared public colour and sends the mix. Each then adds its own secret to the other's mix, and both end up with the same final colour. An eavesdropper sees only the mixes and can't un-mix them. Real HTTPS does this with mathematics, such as elliptic-curve Diffie–Hellman, which is easy to compute forwards and infeasible to reverse.
Proving it's really the website
A secret key is useless if you agreed it with an impostor. So the website also presents a certificate: a document saying "this key belongs to example.com", digitally signed by a certificate authority that your browser already trusts. The site proves it holds the matching private key by signing part of the handshake. If anything doesn't check out, your browser shows a warning.
The handshake in a blink
All of this, the TLS handshake, happens in a few tens of milliseconds when you open a site: agree on settings, exchange key shares, check the certificate, derive the session keys. After that every request and response is encrypted and protected against tampering.
What the padlock doesn't mean
- It doesn't mean the site is trustworthy. Scam sites get certificates too. It only means the connection is private and you are talking to the domain shown.
- It doesn't hide which site you visit. Your provider can usually still see the domain name, just not the pages or data.
- It doesn't protect a hacked device. Malware on your computer can read data before it is encrypted.
Questions people ask
What does the S in HTTPS stand for?
“Secure”. It is ordinary HTTP, the language of the web, carried inside an encrypted TLS connection.
Is public WiFi safe with HTTPS?
HTTPS protects the content of your connection to each site, which makes public WiFi much safer. Be wary of certificate warnings and of fake networks posing as real ones.
What happens when a certificate expires?
Browsers show a warning because they can no longer confirm the key belongs to the site. Sites renew certificates regularly, often automatically.
Can quantum computers break HTTPS?
Large future quantum computers could break today’s key-exchange maths, so browsers and servers are already adding quantum-resistant key exchange alongside it.
What is end-to-end encryption?
In messaging apps, messages are encrypted on your device and only decrypted on the recipient’s, so even the service provider can’t read them. HTTPS protects the link between you and a server.
Test yourself
Pick an answer for each question. Every answer comes with an explanation.
0/4 answered01What does HTTPS protect?
02Why can’t the browser just send the secret key to the website?
03What does the website’s certificate prove?
04Does the padlock mean a site is safe to buy from?
Sources & more
Sources
- HTTPS (Wikipedia)(opens in a new tab)
- Diffie–Hellman key exchange (Wikipedia)(opens in a new tab)
- Transport Layer Security (Wikipedia)(opens in a new tab)
- How it works (Let’s Encrypt)(opens in a new tab)
Last updated 2026-11-26
Keep exploring
- Internet & WirelessExplore it
How does Bluetooth work?
- Internet & WirelessExplore it
How does WiFi work?
- Internet & WirelessExplore it
How does a QR code work?
- Internet & WirelessExplore it
How does GPS work?
- Internet & WirelessExplore it
How do mobile networks (4G and 5G) work?
- Internet & WirelessExplore it
How do fibre-optic cables work?