← IGCSE Computer Science Paper 1

Encryption key

A secret value used by the encryption algorithm to scramble data into ciphertext and unscramble it again. A different key gives different ciphertext, and a longer key is harder to guess.

Understanding Encryption key in IGCSE Computer Science Paper 1

What it does: The same message and algorithm give two different results because the keys 1 and 2 are different. Decryption uses the key to reverse the scrambling, so the original plaintext is recovered. The key is a value used by the encryption algorithm. The message before encryption is called plaintext. The algorithm can be public. The security depends on the key staying secret. A longer key has many more possible values, so an attacker needs far more guesses. Knowing the algorithm is not enough. Without the correct key the ciphertext stays scrambled. The shift value (for example 3) is the key. The shifting method is the algorithm.

Common mistakes: To scramble plaintext into ciphertext you call encrypt, not decrypt. Line 3 should be cipher ← encrypt(text, key). The ciphertext was made with key 5, so it must be unscrambled with the same key. Using 7 gives the wrong text. It should be decrypt(cipher, key).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 189–203) and word search (Modules 189–217).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does an encryption key do?
It is a value the algorithm uses to scramble and unscramble dataIt is the message that is being sent
Matches
A hacker who knows the algorithm can read the data without the key
↓
The algorithm can be public. Security depends on keeping the key secret, so knowing the algorithm alone does not let someone read the data.
Applying
Meanings
Term
encryption key
Meaning
A secret value used by the encryption algorithm to scramble data into ciphertext and unscramble it again. A different key gives different ciphertext, and a longer key is harder to guess.
Practice
// Algorithm is public, key is secret
Testing
Gaps
ciphertext ← encrypt(plaintext, )
Check Answer
Spots
2text ← "HELLO"
3cipher ← decrypt(text, key)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Ostrich' badge — Full Sprint, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does an encryption key do?
A. It is the message that is being sent
B. It is a value the algorithm uses to scramble and unscramble data ✓
The key is a value used by the encryption algorithm. The message before encryption is called plaintext.
2. Which part of encryption needs to be kept secret?
A. The key ✓
B. The algorithm
The algorithm can be public. The security depends on the key staying secret.
3. The same plaintext is encrypted with two different keys. What happens?
A. The ciphertext is identical both times
B. The ciphertext is different each time ✓
A different key gives different ciphertext, even when the plaintext and algorithm are the same.
4. Which key is harder to guess?
A. A longer key ✓
B. A shorter key
A longer key has many more possible values, so an attacker needs far more guesses.
5. An attacker knows the algorithm used but not the key. Can they easily read the data?
A. No, they still need the key ✓
B. Yes, the algorithm alone is enough
Knowing the algorithm is not enough. Without the correct key the ciphertext stays scrambled.

Match the Pairs

key = 3 → Sets the secret value the algorithm uses to scramble the data, here a Caesar shift of 3
ciphertext = encrypt(plaintext, key) → The algorithm uses the key to scramble the plaintext into ciphertext
A different key gives different ciphertext, even with the same algorithm and plaintext → encrypt("HI", 1) != encrypt("HI", 2)
The same key is used to unscramble the ciphertext back into the plaintext → plaintext = decrypt(ciphertext, key)
A hacker who knows the algorithm can read the data without the key → The algorithm can be public. Security depends on keeping the key secret, so knowing the algorithm alone does not let someone read the data.
A shorter key is harder to guess than a longer key → A longer key has many more possible values, so it is harder to guess. A shorter key is easier to guess.

Key Term

encryption key
A secret value used by the encryption algorithm to scramble data into ciphertext and unscramble it again. A different key gives different ciphertext, and a longer key is harder to guess.

Fill in the Blanks

1. ciphertext ← encrypt(plaintext, key)
Hint: Type the name of the secret value the algorithm uses to scramble the data.
2. plaintext ← decrypt(ciphertext, key)
Hint: Type the function name that uses the key to unscramble ciphertext.
3. IF LENGTH(key) >= 128 THEN OUTPUT "Harder to guess" ENDIF
Hint: Type the function that finds how long the key is, because a longer key is harder to guess.
4. // The algorithm can be public // The key must stay secret ciphertext ← encrypt(plaintext, key)
Hint: Type the one item that must be kept secret, even when the algorithm is public.
5. c1 ← encrypt(plaintext, key1) c2 ← encrypt(plaintext, key2) OUTPUT c1 ≠ c2
Hint: Type the name of the different key variable that gives a different ciphertext.

Spot the Error

Question 1
A key ← 3
B text ← "HELLO"
C cipher ← decrypt(text, key)
D OUTPUT cipher
Line C — To scramble plaintext into ciphertext you call encrypt, not decrypt. Line 3 should be cipher ← encrypt(text, key).
Question 2
A key ← 5
B cipher ← "MJQQT"
C text ← decrypt(cipher, 7)
D OUTPUT text
Line C — The ciphertext was made with key 5, so it must be unscrambled with the same key. Using 7 gives the wrong text. It should be decrypt(cipher, key).
Question 3
A c1 ← encrypt("CAT", 1)
B c2 ← encrypt("CAT", 1)
C IF c1 <> c2 THEN
D OUTPUT "Different"
E ENDIF
Line B — The program shows that a different key gives different ciphertext. Line 2 reuses key 1, which would give the same ciphertext as c1. It should use key 2.
Question 4
A OUTPUT "Key: 7f3a9c"
B key ← "7f3a9c"
C cipher ← encrypt(text, key)
D OUTPUT cipher
Line A — The algorithm can be public, but the key must stay secret. Printing the key lets anyone decrypt the data. Line 1 should output the algorithm name, not the key.
Question 5
A IF len(keyA) < len(keyB) THEN
B OUTPUT "A is harder"
C ELSE
D OUTPUT "B is harder"
E ENDIF
Line A — A longer key is harder to guess. The condition must check that keyA is longer than keyB using >, otherwise the wrong key is reported as harder.

Student with a class code? Join your class →