HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Encryption: Symmetric and Asymmetric Keys
  1. 1Why we encrypt data
  2. 2Symmetric encryption
  3. 3Asymmetric encryption: public and private keys
  1. Computer Science
  2. /Encryption: Symmetric and Asymmetric Keys
  3. /Why we encrypt data

Course 2.3·Lesson 1 of 3

Why we encrypt data

Data that crosses a network can be copied by anyone who taps into it. This lesson explains why data is encrypted before it is sent, and the words you need: plaintext, ciphertext, key, encryption and decryption.

about 25 min1 simulation1 practice question
Lesson 1 of 3Show all lessonsHide
Encryption: Symmetric and Asymmetric Keys
  1. 1Why we encrypt data
  2. 2Symmetric encryption
  3. 3Asymmetric encryption: public and private keys

Try the code and the simulations beside the lesson.

Anyone can listen

Think of a postcard. On its way to your friend, it passes through many hands, and anyone can read it. Data on a network is like that. Packets pass through cables, routers and the air. A person with the right equipment can intercept them: copy them as they go past, without the sender or the receiver knowing.

Some data must stay private: passwords, bank details, medical records, private messages. We cannot stop every interception. So we make the data meaningless to anyone who intercepts it. That is the purpose of encryption.

Encryption scrambles data so that it cannot be understood without a key. It does not stop the data being intercepted. It stops the intercepted data being understood.

The words you need

  • Plaintext: the original data, which anyone could read.
  • Ciphertext: the scrambled data after encryption. It looks like nonsense.
  • Encryption algorithm: the method that turns plaintext into ciphertext.
  • Key: a value the algorithm uses. A different key gives different ciphertext from the same plaintext.
  • Decryption: turning ciphertext back into plaintext, which needs the right key.
A flow from left to right. The plaintext SEND THE FILE goes into a box labelled encryption algorithm, with a key of 3 fed in from above. Out comes the ciphertext VHQG WKH ILOH, which crosses a network where an attacker intercepts a copy but sees only nonsense. At the right, a decryption box with the key 3 turns the ciphertext back into SEND THE FILE.

A first example: the shift cipher

A very old method shifts every letter along the alphabet by the same number of places. The number of places is the key. With the key 333, A becomes D, B becomes E, and at the end of the alphabet we go round again: X becomes A, Y becomes B and Z becomes C.

  • Plaintext: SEND THE FILE
  • Key: 333
  • Ciphertext: VHQG WKH ILOH

To decrypt, shift back by 333. A person who intercepts VHQG WKH ILOH sees nonsense, unless they know or guess the key.

If we number the letters A =0= 0=0, B =1= 1=1, up to Z =25= 25=25, the rule is c=(p+k) mod 26c = (p + k) \bmod 26c=(p+k)mod26. Here ppp is the plaintext letter, kkk is the key and ccc is the ciphertext letter. The word  mod \bmodmod means "the remainder after dividing by", so the count wraps round after Z.

The shift cipher is far too weak for real use, because there are only 252525 useful keys, and a computer can try them all at once. But it shows the idea of every encryption method: an algorithm, a key, and ciphertext that is useless without the key. The exam does not ask you to carry out a shift cipher.

Practise with new numbers

Try it in Python

The program encrypts a message with a shift cipher and the key 333. Then it decrypts it by shifting back with the key −3-3−3.

Read it first. Then run it. Is the second line the original message?

1. Change the key to 10 in both places. Predict the first letter of the ciphertext.

2. Decrypt with the wrong key, -2. What does the result look like?

Common mistakes

  • Saying encryption stops hackers getting the data. They can still intercept it. They just cannot understand it.
  • Mixing up plaintext and ciphertext. Plaintext is the readable original. Ciphertext is the scrambled form.
  • Thinking the algorithm must be secret. The methods used today are well known. The secret is the key.

Remember these

  • Data can be intercepted on its way across a network.
  • Encryption makes intercepted data meaningless without the key; it does not stop interception.
  • Plaintext, encryption algorithm and key give ciphertext; decryption with the right key gives the plaintext back.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. What does encryption do to intercepted data?
  1. What is the name for the original, readable data?
  1. Encrypt the word CAB with a shift cipher and the key 222.
  1. A shift cipher with the key 444 turns a letter into B. Which letter was it?
  1. Give two kinds of data that should be encrypted before they are sent.

Enroll free in Encryption: Symmetric and Asymmetric Keys

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

Priya encrypts the word MEET with a shift cipher and the key 4…Easy · High School (9–10) · by StemPy Lab
Kwame intercepts a message made with a shift cipher…Medium · High School (9–10) · by StemPy Lab
An attacker learns that, with a certain shift cipher key, the letter S was encrypted as B…Hard · High School (9–10) · by StemPy Lab
Next: lesson 2Symmetric encryption
← Encryption: Symmetric and Asymmetric Keys
← PreviousSymmetric encryption →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.