How Encryption Keeps Data Private
From Caesar ciphers to AES and RSA — how symmetric and asymmetric encryption work, how HTTPS uses both, and what 'end-to-end encrypted' actually means.
Encryption is the mathematical transformation of readable information into unintelligible noise — and the ability to reverse that transformation only if you possess the right key. It protects your messages, your financial transactions, your passwords in transit, and the contents of your hard drive. Despite being described in headlines as “unbreakable,” modern encryption is not magic; it is mathematics. Understanding how it works demystifies both its power and its limits.
A Simple Starting Point: The Caesar Cipher
Julius Caesar reportedly sent military dispatches by shifting each letter of the alphabet by three positions: A became D, B became E, and so on. “ATTACK” became “DWWDFN.” The cipher is trivially easy to break today, but it illustrates the core concept: a transformation controlled by a shared secret (in this case, the shift value of 3).
A modern encryption algorithm is a vastly more complex transformation — one that produces output that looks completely random and reveals nothing about the input without the key. But the structure is the same: an algorithm applied with a key produces ciphertext; the same algorithm with the same key reverses the process.
Symmetric Encryption
In symmetric encryption, the same key is used to both encrypt and decrypt the data. Both the sender and the receiver must have a copy of the secret key — and they must have agreed on it securely in advance, which is the central challenge.
The standard symmetric encryption algorithm in use today is AES (Advanced Encryption Standard), adopted by the US National Institute of Standards and Technology in 2001. AES operates on fixed-size blocks of data (128 bits) and supports key sizes of 128, 192, or 256 bits. With a 256-bit key, the number of possible keys is 2^256 — a number so large that exhaustively trying every possible key with all the computing power on Earth would take longer than the age of the universe.
Symmetric encryption is fast. Modern hardware can encrypt and decrypt gigabytes of data per second using AES. This speed makes it the right choice for encrypting large amounts of data: files on a disk, streaming video, bulk network traffic.
The problem is key distribution. If you want to communicate privately with someone you have never met before, how do you both end up with the same secret key without an eavesdropper intercepting it? You cannot safely send the key over an insecure channel — that is the very channel you are trying to secure.
Asymmetric Encryption and Key Pairs
Asymmetric encryption solves the key distribution problem by using a mathematically linked pair of keys: a public key and a private key. What one key encrypts, only the other can decrypt.
You can freely share your public key with anyone — post it on a website, send it in an email, put it on a business card. Anyone who wants to send you a secret message encrypts it with your public key. The resulting ciphertext can only be decrypted by the corresponding private key, which only you hold. Even the person who encrypted the message cannot decrypt it without your private key.
The mathematics underlying this relies on problems that are easy to perform in one direction but computationally infeasible to reverse. RSA, one of the most widely used asymmetric algorithms, exploits the fact that multiplying two large prime numbers together is trivial, but factoring the product back into its prime components is prohibitively difficult for large enough numbers. Elliptic curve cryptography (ECC), increasingly preferred for efficiency, exploits similar one-way properties of geometric operations over finite fields.
Asymmetric encryption is computationally slow compared to symmetric encryption — roughly 1,000 times slower. This makes it impractical for encrypting large amounts of data.
Hybrid Encryption: Combining Both
In practice, real-world systems use both types of encryption together:
- Asymmetric encryption is used to securely exchange a session key — a randomly generated symmetric key.
- All actual data is then encrypted with the much faster symmetric algorithm using that session key.
Neither party ever sends the session key in plain text — they derive or exchange it using asymmetric cryptography. Once both parties have the same session key, symmetric encryption does the heavy lifting. This is the hybrid approach, and it underlies HTTPS, TLS, SSH, and almost every other secure communication protocol.
Digital Signatures: Proving Authenticity
Asymmetric key pairs also enable digital signatures, which solve a different problem: how do you prove that a message actually came from the claimed sender?
The process works in reverse to encryption. To sign a document, you apply your private key to a mathematical hash of the document. The hash is a fixed-length fingerprint of the content — change a single character and the hash changes completely. The signature is a cryptographic proof that someone who holds your private key computed a hash of this specific content at this specific moment.
Anyone who has your public key can verify the signature: they compute the same hash of the document independently and verify that the signature was indeed produced by the corresponding private key. If the signature verifies, two things are proven: the content has not changed since it was signed, and the signature was produced by whoever holds the private key.
Digital signatures are how software update mechanisms verify that a downloaded update actually came from the software vendor. They are how certificate authorities vouch for TLS certificates. They underpin the chain of trust in the TLS/HTTPS system.
TLS and HTTPS: Putting It All Together
When your browser establishes an HTTPS connection, the entire sequence described above happens automatically in a second or less:
- The server presents a digital certificate — a document containing its public key and details about its identity, signed by a trusted Certificate Authority.
- Your browser verifies the certificate’s signature using the CA’s public key (which is pre-installed in your browser and operating system).
- Both sides use the server’s public key and some additional randomness to derive a shared session key without transmitting it directly (using a protocol called the key exchange portion of TLS).
- All subsequent communication — the actual HTTP requests and responses — is encrypted symmetrically using the session key.
An eavesdropper who intercepts the traffic sees only the initial certificate exchange (which is public information) and then meaningless encrypted bytes.
End-to-End Encryption
End-to-end encryption (E2EE) refers to a specific design in messaging systems where messages are encrypted on the sender’s device and can only be decrypted on the recipient’s device. The service provider who carries the messages in transit cannot read them, because the keys are held only by the participants.
This is distinct from encryption in transit (like HTTPS), where the service provider can read the decrypted messages on their servers before re-encrypting them for storage. In an E2EE system, the provider’s servers see only ciphertext they cannot decrypt — not because they are prevented from trying, but because they never have the keys.
E2EE requires careful key management: how do you verify that the public key you have for a contact genuinely belongs to them, and not to an impostor the service has substituted? This is the key verification problem, and it is why some secure messaging applications offer “safety number” comparisons or similar mechanisms for verifying that communication is genuinely private.
What “Unbreakable” Really Means
Properly implemented modern encryption is not broken by attacking the mathematics directly. The mathematics is genuinely too hard — with current computers and algorithms, brute-forcing a 256-bit AES key is computationally infeasible for thousands of years.
Real-world attacks target everything around the mathematics: weak passwords used as keys, implementation bugs that leak key material, compromised endpoints (the devices that hold the keys), or supply-chain attacks on the software that performs the encryption. The algorithm is the strongest link in the chain. The surrounding system is where adversaries look.
Encryption gives you strong, reliable mathematical protection for your data. What it cannot do is protect you from a device that is already compromised, a password that is guessable, or a system implemented carelessly. Understanding where the boundary of its protection lies is as important as knowing that the protection exists.