Encryption

Computer Science · Data transmission. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science topics

The idea

Data sent over a network can be intercepted. Encryption does not stop this. It scrambles the data so that anyone who intercepts it cannot understand it.

The original readable data is called plaintext. An encryption algorithm and a key turn it into ciphertext. Only someone with the correct key can turn the ciphertext back into plaintext.

In symmetric encryption the same key is used to encrypt and decrypt, so the key must be shared, and it could be intercepted on the way. Asymmetric encryption solves this by using two different keys that work as a pair.

In simpler words

Anyone might grab data as it travels across a network. Encryption does not stop that. It scrambles the data so it makes no sense to them. Readable data is called plaintext. Scrambled data is called ciphertext. A key turns one into the other. Symmetric encryption uses one shared key. Asymmetric uses a public key and a private key.

An everyday comparison

Asymmetric encryption is like a postbox with a slot. Anyone can drop a letter in, which is the public key, but only the owner has the key to open it and read the letters, the private key. The comparison stops working because a real postbox can be broken open, while strong encryption is designed to be practically impossible to undo without the private key.

Rules to remember

Common mistake

Students say the sender encrypts with their own public key. The sender uses the receiver's public key, and the receiver decrypts with the receiver's own private key.

In the exam

Define plaintext and ciphertext, then state that encryption does not stop interception but makes the data meaningless. For symmetric, say one key encrypts and decrypts and must be shared, so it could be intercepted. For asymmetric, write the steps: the receiver's public key is used to encrypt, and only the receiver's matching private key can decrypt. Never say the sender uses their own public key.

Worked example

Sara types her card number into an online shop that uses asymmetric encryption. Which keys are used, and by whom?

  1. The shop's public key is sent to Sara's browser. This is safe because a public key can be seen by anyone.
  2. Sara's browser encrypts the card number with the shop's public key, giving ciphertext.
  3. Only the shop's private key matches that public key, and the shop never shares it.
  4. A hacker who intercepts the ciphertext has no private key, so cannot read it.

Answer: Sara's browser encrypts with the shop's public key; the shop decrypts with its own private key.

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← Methods of error detectionComputer architecture →Take a Computer Science test