Find a course

Module 4: Networks and EncryptionLesson 9 of 1214 min

Encryption, Hashing and Certificates

Distinguish symmetric and public-key encryption, hashing and digital signatures, and see how they combine in TLS to secure every HTTPS connection.

Step 1 of 12Learn

From Caesar to AES

More than 2,000 years ago, Julius Caesar reportedly protected messages by shifting each letter three places down the alphabet: A became D, B became E. Anyone who knew the key (shift by 3) could reverse it. The method is trivially breakable today, since there are only 25 possible shifts to try, but it shows the basic parts of all encryption:

  • Plaintext: the readable message.
  • Algorithm (cipher): the method used to scramble it.
  • Key: the secret value that controls the scrambling.
  • Ciphertext: the scrambled result.

Modern security assumes the attacker knows the algorithm; only the key is secret. This idea, known as Kerckhoffs's principle, is why trustworthy algorithms are public and heavily studied. Secret homemade algorithms almost always turn out to be weak.

In symmetric encryption, the same key encrypts and decrypts. The standard today is AES (Advanced Encryption Standard), used for disk encryption, Wi-Fi, messaging apps and the bulk of HTTPS traffic. It's extremely fast, and a 128-bit key has 2128 possible values, about 3.4 × 1038. Even trying a trillion trillion keys per second, a brute-force search would take vastly longer than the age of the universe.

Symmetric encryption has one big problem: key distribution. Both sides need the same secret key. How do you share it with a website you've never visited, over a network attackers might be watching?

Step 2 of 12Practice · Fill in the blanks

Fill in the blanks

In symmetric encryption, the key is used to encrypt and decrypt. The most widely used symmetric cipher today is .

Step 3 of 12Practice · Diagram

How many keys would a brute-force attack try?

Which cipher’s key space was small enough to be brute-forced in the 1990s?

Tap the shape that answers the question, then press Check.

How many keys would a brute-force attack try?Scale: Caesar shift, 4-digit PIN, DES (56-bit), AES-128, AES-256.110¹¹10²²10³³10⁴⁴10⁵⁵10⁶⁶10⁷⁷25 keysCaesar shift10,000 keys4-digit PIN7.2 × 10¹⁶ keysDES (56-bit)3.4 × 10³⁸ keysAES-1281.16 × 10⁷⁷ keysAES-256
Caesar shift

25 possible shifts: breakable by hand in minutes.

4-digit PIN

10,000 options; trivial for a computer.

DES (56-bit)

About 7 × 1016 keys. Publicly brute-forced in 1998 with custom hardware.

AES-128

About 3.4 × 1038 keys; far beyond any brute-force attack.

AES-256

About 1.2 × 1077 keys.

Step 4 of 12Learn

Public-key cryptography

In the 1970s, researchers found an elegant answer to the key distribution problem: public-key (asymmetric) cryptography. Each person or server has a key pair:

  • A public key, which can be shared with anyone.
  • A private key, which never leaves its owner.

The keys are mathematically linked, but you can't realistically work out the private key from the public one. Common algorithms are RSA and elliptic-curve cryptography (ECC).

The pair supports two different operations:

Encryption for confidentiality. Anyone can encrypt a message with your public key, and only your private key can decrypt it. It's like a mailbox with a slot: anyone can drop a letter in, only the owner has the key to open it.

Digital signatures for authenticity and integrity. You sign data with your private key, and anyone can verify the signature with your public key. A valid signature proves the data came from the holder of the private key and wasn't changed afterward. Software updates are signed this way, so your computer can reject a tampered update.

Public-key operations are much slower than symmetric ones, so real systems combine them: public-key methods are used to authenticate and to agree on a fresh symmetric key, and then fast AES encrypts the actual data. This hybrid approach is exactly how HTTPS works.

Step 5 of 12Practice · Match the pairs

Match each goal to the key that is used.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. Encrypt a message so only Bob can read it
  2. Decrypt a message sent to Bob
  3. Sign a document as Alice
  4. Verify Alice's signature

Step 6 of 12Diagram

Sending Bob a secret with public-key encryption

Sending Bob a secret with public-key encryptionProcess diagram: Alice gets Bob’s public key → Alice encrypts with it → Ciphertext crosses the internet → Bob decrypts with his private key.Alice getsBob’s publickeyAlice encryptswith itCiphertextcrosses theinternetBob decryptswith hisprivate key

Tap a shape with to see more.

Alice gets Bob’s public key

Anyone may have it; it is published openly.

Alice encrypts with it
Ciphertext crosses the internet

An eavesdropper sees only scrambled bytes.

Bob decrypts with his private key

Only the private key reverses it, and it never left Bob’s device.

Step 7 of 12Learn

Hashes are not encryption

A hash function takes any input, a password, a file, a whole hard drive, and produces a fixed-length output called a hash or digest. SHA-256 always produces 256 bits, usually shown as 64 hexadecimal characters.

Good cryptographic hashes have three key properties:

  • One-way: you can't recover the input from the hash.
  • Deterministic: the same input always gives the same hash.
  • Avalanche effect: changing a single character of the input changes the hash completely and unpredictably.

That makes hashes ideal for integrity checks. A software download page might list the SHA-256 hash of the installer; after downloading, you compute the hash yourself, and if it matches, the file hasn't been corrupted or altered. Hashes also underpin password storage, digital signatures (you sign the hash of a document rather than the whole thing) and blockchains.

The big conceptual point: encryption is reversible with the key; hashing is not reversible at all. You encrypt things you need to read again later, such as files and messages. You hash things you only need to compare, such as passwords and file fingerprints.

Old hash functions such as MD5 and SHA-1 are considered broken for security purposes, because researchers can create two different inputs with the same hash (a collision). Use SHA-256 or newer for integrity, and slow password hashes like bcrypt or Argon2 for passwords.

Step 8 of 12Practice · Sort into groups

For each task, should you use encryption or hashing?

Tap an item, then tap its group (or drag it there).

Step 9 of 12Compare

Encryption vs hashing

AspectEncryptionHashing
Reversible?Yes, with the right keyNo, one-way by design
Uses a key?YesNo (a salt is not a secret key)
Output sizeGrows with the inputFixed, e.g. 256 bits for SHA-256
Protects mainlyConfidentialityIntegrity
Typical useFiles, disks, network trafficPassword storage, file fingerprints

Step 10 of 12Tap to reveal

How TLS secures a website connection

  1. 1. Hello

    Your browser connects and lists the encryption methods it supports. The server picks the strongest shared option.

  2. 2. Certificate

    The server sends its digital certificate: its public key plus its domain name, signed by a certificate authority (CA) that your browser already trusts.

  3. 3. Verification

    The browser checks the CA's signature, the expiry date and that the domain in the certificate matches the site you asked for. If anything fails, you see a full-page warning.

  4. 4. Key agreement

    Using public-key math, browser and server agree on a fresh symmetric session key that an eavesdropper cannot calculate, even if they recorded every message.

  5. 5. Encrypted traffic

    All further data is encrypted with fast symmetric encryption such as AES, and each message is integrity-checked so tampering is detected.

Step 11 of 12Practice · True or false

A padlock icon and HTTPS prove that a website is legitimate and safe to enter your password into.

Step 12 of 12Practice · Choose one

Why does HTTPS use public-key cryptography and symmetric encryption together?