Energy and Everyday Technology

How Encryption Keeps Messages Private

A conceptual look at encryption: how keys and scrambling turn readable data into unreadable data, and the difference between shared-key and public-key ideas.

On this page
  1. The basic idea
  2. An old and simple example
  3. What makes modern encryption different
  4. Shared-key encryption
  5. Public-key encryption
  6. How the two are combined
  7. Other uses of the same ideas
  8. Limits

The basic idea

Encryption is the process of turning readable information, called plaintext, into a scrambled form, called ciphertext, in such a way that only someone with the right secret can turn it back. The scrambling procedure is called a cipher or algorithm, and the secret is called a key.

The important idea is the separation of the two. The procedure can be public and well studied. What must stay secret is the key. A good system is designed so that knowing how it works does not help you read a message without the key.

This article only explains the concept. It is not a guide to protecting yourself or choosing tools.

An old and simple example

One of the oldest ciphers is attributed to Julius Caesar, who is said to have shifted letters of the alphabet by a fixed number of places. Suppose the shift is 3, so each letter is replaced by the letter three places later. The word HELLO becomes KHOOR: H moves to K, E to H, L to O, L to O and O to R.

To decrypt, the receiver shifts each letter three places back. Here the key is the number 3.

This cipher is extremely weak. There are only 25 useful shifts, so anyone can try them all in a few minutes. Letter frequencies also give clues, since some letters, such as E in English, appear more often than others. The example shows the pattern, not a method that is safe to use.

What makes modern encryption different

Modern ciphers are carried out by computers and operate on the binary data that represents text, images and files. Instead of shifting letters, they mix and rearrange bits through many rounds of mathematical operations. A well-designed cipher makes the output look random, so that patterns in the original data do not show through.

Strength depends largely on the size of the key. Each additional bit in a key doubles the number of possible keys. A key of 128 bits has an astronomically large number of possibilities, far beyond what anyone could try one by one. That is the basic reason trying every key is not considered practical against well-designed systems. In practice, attacks tend to target weaknesses elsewhere, such as flawed software or human error, rather than the math itself.

Shared-key encryption

In shared-key, or symmetric, encryption, the sender and receiver use the same key to lock and unlock the data. It is fast and well suited to large amounts of data, such as a whole file or a stream of video.

Its difficulty is the key distribution problem. If two people have never met, how do they agree on a secret key without anyone else learning it? Sending the key over the same open channel defeats the purpose.

Public-key encryption

Public-key, or asymmetric, encryption was developed to address that problem, with major public ideas emerging in the 1970s. Each person has a pair of mathematically linked keys. One, the public key, can be shared with anyone. The other, the private key, is kept secret.

A common analogy is a padlock. You could hand out many open padlocks to anyone. Anyone can snap one shut on a box, but only you hold the key that opens it. In the same way, anyone can encrypt a message with your public key, but only your private key can decrypt it.

The mathematics relies on problems that are easy to do in one direction but believed to be very hard to reverse. A standard example is multiplying two large prime numbers, which is quick, versus finding the two primes from the product alone, which becomes extremely slow as the numbers grow. Whether any such problem is truly hard is not mathematically proven in every case, which is one reason researchers keep studying and updating the methods.

How the two are combined

Public-key methods are generally slower than shared-key methods. So many systems use a hybrid approach: public-key techniques are used briefly at the start to agree on a fresh shared key, and then the faster shared-key cipher protects the bulk of the data. This is roughly what happens behind the scenes when a browser connects to a website securely, as part of how the internet works.

Other uses of the same ideas

Related techniques can do jobs besides secrecy. A digital signature lets a person use a private key to show a message came from them and was not changed. A hash function turns data of any size into a short fixed-length fingerprint, which changes completely if the data changes even slightly. These are used to check that files and messages are authentic.

Limits

Encryption protects data from being read by people who lack the key. It does not make a device, a password or a person automatically trustworthy. If the key leaks or the software has bugs, the protection fails. Encryption is also only one part of broader security, and the details of protecting a specific system are best left to qualified professionals.

The central takeaway is simple: a secret key plus a public, well-tested scrambling method lets readable information be made unreadable to everyone except the intended recipient.

The complete guide to energy and everyday technology

How Energy Powers Modern Life
Read the guide

Keep exploring

Guides from other topics

All topics →