Please enable JavaScript to use CodeHS

Cybersecurity basics

What Is End-to-End Encryption?

When you send a chat, it travels through computers owned by a company. End-to-end encryption is the lock that keeps that company, and anyone else in the middle, from reading it. Learn how it works, which apps use it, and what it cannot do.

Cybersecurity ~12 min Beginner friendly
decrypt.log
What the server sees What your friend readsMeet me at the park at 3. Bring snacks!
The basics

What encryption is

Encryption is a way to scramble a message so only the right person can read it. If you are wondering how encryption works, it comes down to three parts.

plaintextThe original message that anyone can read. Example: Meet me at 3.
ciphertextThe scrambled version. Example: Zq8#vL0@t. It looks like nonsense.
keyA secret value that locks the message (encrypts it) or unlocks it (decrypts it).
algorithmThe recipe of math steps that mixes the message with the key.

So the plan is simple. Plaintext goes in. The algorithm mixes it with a key. Ciphertext comes out. Anyone who grabs the ciphertext sees nonsense. Only someone with the right key can turn it back into plaintext.

Think of a diary with a lock. The diary is the message. The lock is the encryption. Anyone can hold the diary, but only the person with the key can read it.

People have used this idea for about 2,000 years. Julius Caesar shifted each letter of his notes by a few places so enemies could not read them. Today your phone does the same kind of thing, but with math so strong that all the computers on Earth could not guess the key in your lifetime.


The problem

The server in the middle

When you text a friend with an app, your message does not fly straight from your phone to theirs. It goes to a server first. A server is a computer, owned by the app's company, that stays on all day and passes messages along. Then the server sends your message to your friend.

That middle step is the problem. There are three common setups:

  • No encryption. The message is plaintext the whole trip. Anyone on the same public Wi-Fi, the company, and anyone who breaks into the company can read it.
  • Encryption in transit. The message is locked while it travels between your phone and the server. This is what https:// and the padlock in your browser mean. People on the Wi-Fi see nonsense. But the server unlocks the message to process it, so the company can read it, and so can anyone who breaks into the server.
  • End-to-end encryption (E2EE). The message is locked on your phone and only unlocked on your friend's phone. The server only ever holds ciphertext. It carries the message but cannot read it.

The "ends" in end-to-end are the two phones. The lock stays on the whole way between them. In the next section, you can watch it happen.


Interactive

Follow the message

Alice is sending a message to Bob. Pick a setup, then press Next hop to move the message along. At every stop, check who could read it.

Setup

Alicesender
Serverthe company
Bobreceiver

Someone snooping on the Wi-FiWatches the network, like on public Wi-Fi
The company's serverThe app's computers and the people who run them
BobThe person it was meant for

The key difference is who holds the key. With encryption in transit, the company holds a key to unlock your message at the server. With end-to-end encryption, the company never gets the key. Only the two phones have it.


Interactive

Try a toy cipher

Type a message and a secret key. The cipher below shifts each character by an amount set by your key. It is the same idea as Caesar's trick, with the shift changing along with your key.

This is a toy. A smart person could crack it in minutes. Real apps use much stronger math, such as the Signal Protocol and the AES cipher, that has no known shortcut. Use this one only to see the idea: same message, different key, different ciphertext.

Toy cipher Toy. Not secure.

Change one letter of the unlock key and the message turns to junk. That is the point. The method can be public. The key is the secret.


The big trick

Public and private keys

Here is a puzzle. If Alice and Bob have never met, how do they agree on a secret key? If they send the key over the internet, someone could copy it.

Apps solve this with two keys that work as a pair. This is called public-key cryptography.

  • The public key locks messages. You can give it to anyone. Posting it online is fine.
  • The private key unlocks messages. It never leaves your phone.

Think of a mailbox with a slot. Anyone can drop a letter in. But only you have the key to open the box and take the letters out. Or think of padlocks: you hand out thousands of open padlocks. Anyone can snap one shut on a box. Only you own the key that opens them.

Bob anyone can drop in public key share freely Alice Meet at 3pm Zq8#vL0@t private key never shared

Why is this safe? The two keys are linked by math that is easy to do in one direction and extremely hard to undo. Knowing the public key does not let you work out the private key. So a spy who copies Bob's public key learns nothing useful.

In a real app, your phone makes this key pair when you install it. The public key goes to the company's server so your friends can find it. The private key stays on your phone. When you message a friend, the app locks the message with their public key. Only their phone can unlock it. (Apps also use fast tricks like swapping in a fresh one-time key for each chat session, but the core idea is the same.)


Know the limits

What it does and does not protect

End-to-end encryption protects one thing very well: the message while it is traveling and while it sits on a server. It does not make you invisible. Here is the honest list.

It does protect

  • Your message from people on the same Wi-Fi.
  • Your message from the company running the app.
  • Your message if hackers break into the company's servers. They only find ciphertext.
  • Your message if someone demands the company hand it over. The company has nothing readable to give.

It does not protect

  • A friend who screenshots it. Once your friend can read it, they can copy it, share it, or show someone.
  • Someone holding your unlocked phone. The messages are readable on your screen. Use a strong passcode.
  • Some backups. A chat backed up to the cloud may be stored without end-to-end encryption, depending on your settings.
  • Metadata. This is data about the message, not the message. It can include who you talk to, when, how often, and from what network. Some apps collect more of it than others.
  • Malware on your device. A bad app on your phone can read the screen after the message is unlocked.
  • Talking to the wrong person. If a scammer pretends to be your friend, the lock works perfectly, for the scammer.

Short version: E2EE protects the road between the phones. It does not protect what happens at either end of the road.


Interactive

Does this protect me?

Six situations. For each one, say whether end-to-end encryption would help. Click an answer to see why. Assume the chat app uses E2EE.

Scenario game Score: 0 / 0

You send a private message while on the school's public Wi-Fi. A classmate runs a tool to capture network traffic. Can they read it?

It protects you. The classmate only captures ciphertext. Without Bob's private key, it is nonsense.

You send a joke to a friend. The friend screenshots it and posts it in a group chat.

It does not. Your friend was allowed to read it, so they can copy it. E2EE only stops people who are not part of the chat. Send only what you would be okay seeing shared.

Hackers break into the app company's servers and download everything stored there. Your chats are in the stolen data. Can they read them?

It protects you. The servers only hold ciphertext. The keys are on the phones, not the servers.

Your little brother picks up your phone while it is unlocked and scrolls through your chats.

It does not. Your phone has already unlocked the messages to show them to you. A passcode and an auto-lock timer protect you here.

You use a messaging app with E2EE. Someone who can see the company's records learns that you messaged the same number 40 times last night. Does E2EE hide this?

It does not. This is metadata. E2EE locks the contents of the message. Who messaged whom, and when, is often still visible to the company, depending on the app.

Your chat app backs up your messages to the cloud, and that backup is not end-to-end encrypted. Does the backup stay private from the cloud company?

It does not. A backup is a separate copy, and it follows its own rules. Some apps let you turn on encrypted backups. Check your settings.

The big debate

Why people argue about it

End-to-end encryption is one of the most argued-about topics in technology. Both sides have real points, so here they are fairly.

The case for keeping it

  • Privacy is normal. You close the door when you talk about private things. E2EE is a door for your messages.
  • It protects people at risk. Journalists, human rights workers, and people escaping abuse rely on it to stay safe.
  • It limits damage from hacks. Stolen servers do not leak readable chats.
  • A secret way in is a way in for everyone. Experts warn that if the company builds a hidden "backdoor" for the good guys, criminals and foreign spies can find it and use it too.

The case for limits

  • Police need evidence. With a court order, police can usually ask a company for messages. With E2EE, the company has nothing readable to give.
  • Harm can hide. Governments point to child safety and serious crime, where messages could help stop abuse.
  • Companies cannot scan. The company cannot check chats for scams or harmful content on its own servers.

Different countries have proposed different answers, from requiring a way in, to scanning messages on the phone before they are locked, to leaving it alone. Each idea has trade-offs, and experts still disagree. Part of being a digital citizen is understanding both sides, so you can form your own view.


Practical

Which apps use it?

Is WhatsApp encrypted? Yes, and end-to-end by default. Here is how some popular choices work. Apps change, so check the app's own help page for the latest details.

AppEnd-to-end by default?Notes
SignalYesBuilt around E2EE. Collects very little metadata.
WhatsAppYesUses the Signal Protocol for chats and calls. Cloud backups are separate, so check the backup encryption setting.
iMessageYes, between Apple devicesBlue bubbles are iMessage. Green bubbles are regular SMS texts, which are not end-to-end encrypted. iCloud backups have their own setting.
TelegramNo, only in "Secret Chats"Normal chats are encrypted to the server, which can read them. Secret Chats are end-to-end, one-to-one only.
SMS text messagesNoPlain text messages are not end-to-end encrypted.
Social media DMs and gaming chatUsually noMany are encrypted in transit only. Look for an option to turn on end-to-end chats.

How to tell for yourself

  • Look for the words. Apps that do it usually say "end-to-end encrypted" in the chat or in settings.
  • Check for a safety number or security code. Signal and WhatsApp let you compare a code with a friend to confirm no one is in the middle.
  • Check each setting. Some apps need you to turn on E2EE chats or backups.
  • Remember the padlock in your browser is not the same. That is encryption in transit to a website, not end-to-end chat.
  • Read the help page. If a company will not clearly say whether it can read your messages, treat it as if it can.

Want more habits like this? See The CIA Triad, which explains why keeping data secret (confidentiality) is one of the three big goals of cybersecurity.


Check yourself

Quick quiz

1. An app uses encryption in transit only. Who can read your message on the server?

2. In public-key encryption, which key is safe to share with everyone?

3. Your chat app uses end-to-end encryption. Which of these is still a risk?


What's next

Keep learning

Keep going with cybersecurity

Now you know how the lock on a chat works. Learn how to build and break these ideas yourself: encryption, passwords, networks, and how real attacks happen.

Explore the CodeHS Cybersecurity course or practice in the CodeHS Cyber Range.

Part of the CodeHS cybersecurity tutorials.