← ACARA Digital Technologies Years 9–10

Key space: how many keys a cipher has

The total number of different keys a cipher allows. A Caesar cipher has only 25 useful keys, so an attacker can try them all. More keys means a bigger key space and a stronger cipher.

Understanding Key space: how many keys a cipher has in ACARA Digital Technologies Years 9–10

What it does: With only 25 keys the loop checks every shift and prints each result, so the attacker soon finds the readable message. A 128-bit key allows 2 to the power of 128 keys, a huge key space that cannot be tried one by one. More possible keys means a bigger key space, which makes trying every key much harder. A shift of 26 returns every letter to itself, so it is not a useful key. That is why the key space is 25. 26 keys is still very easy to try. The key space must grow a lot to stop brute force.

Common mistakes: Key 0 leaves the message unchanged, so a Caesar cipher has 26 - 1 = 25 useful keys. It should be keys = letters - 1. A cipher with 2 ** 128 keys has a much bigger key space than a Caesar cipher with 25 keys. The test should be bigger > caesar.

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 828–859) and word search (Modules 810–859).

Take this worksheet further — free with Cloodit

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

Learning
Duo
How many useful keys does a Caesar cipher have?
Millions25
Matches
A Caesar cipher has 100 keys, so it is hard to brute force.
↓
A Caesar cipher has only 25 useful keys, not 100. That small key space makes it easy to brute force.
Applying
Meanings
Term
key space
Meaning
The total number of different keys a cipher allows. A Caesar cipher has only 25 useful keys, so an attacker can try them all. More keys means a bigger key space and a stronger cipher.
Practice
keys = 26 - 1
Testing
Gaps
keys = 26 1
Check Answer
Spots
2useless_key = 0
3keys = letters + 1

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

The 'Lion's Mane Jellyfish' badge — Set Operator, 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. How many useful keys does a Caesar cipher have?
A. Millions
B. 25 ✓
Shifts 1 to 25 give 25 useful keys. A shift of 0 or 26 leaves the message unchanged.
2. What does the term key space mean?
A. The blank space between words in a message
B. The total number of different keys a cipher allows ✓
Key space counts every possible key. A bigger key space means more keys for an attacker to try.
3. Why is a Caesar cipher easy to break by trying every key?
A. Its key space is tiny, so all 25 keys can be tested quickly ✓
B. Its key space is huge, so attackers get lucky
With only 25 keys, an attacker can test every shift in seconds and read the one that makes sense.
4. Which cipher has the stronger key space?
A. A cipher with 1 000 000 possible keys ✓
B. A cipher with 25 possible keys
More possible keys means a bigger key space, which makes trying every key much harder.
5. An attacker intercepts a Caesar ciphertext. What is the simplest attack?
A. Try all 25 shifts and look for readable text ✓
B. Guess one shift and give up if it fails
Trying every key is called brute force. It works well when the key space is small.

Match the Pairs

key_space = 25 → A Caesar cipher has 25 useful keys, so its key space is small
for key in range(1, 26): → Tries every possible Caesar key one after the other
A small key space means an attacker can try every key (brute force) → for shift in range(1, 26): print(shift, decrypt(text, shift))
A bigger key space is stronger because there are far more keys to try → keys = 2 ** 128
A Caesar cipher has 100 keys, so it is hard to brute force. → A Caesar cipher has only 25 useful keys, not 100. That small key space makes it easy to brute force.
Fewer keys make a cipher stronger because there is less to guess. → It is the other way round. Fewer keys means a smaller key space, which is easier for an attacker to try in full.

Key Term

key space
The total number of different keys a cipher allows. A Caesar cipher has only 25 useful keys, so an attacker can try them all. More keys means a bigger key space and a stronger cipher.

Fill in the Blanks

1. keys = 26 - 1
Hint: Type the operator that removes the one shift that changes nothing.
2. for key in range(1, 26): print(key)
Hint: Type the function that makes a sequence of numbers so every key gets tried.
3. keyspace = 25 print(keyspace)
Hint: Type the number of useful keys a Caesar cipher has.
4. for key in range(1, 26): print(decrypt(msg, key))
Hint: Type the loop variable that passes each key to decrypt in turn.
5. keysA = 25 keysB = 2 ** 128 stronger = keysB > keysA
Hint: Type the comparison operator that checks if cipher B has more keys than cipher A.

Spot the Error

Question 1
A letters = 26
B useless_key = 0
C keys = letters + 1
D print(keys)
Line C — Key 0 leaves the message unchanged, so a Caesar cipher has 26 - 1 = 25 useful keys. It should be keys = letters - 1.
Question 2
A caesar = 25
B bigger = 2 ** 128
C if bigger < caesar:
D print('Stronger')
Line C — A cipher with 2 ** 128 keys has a much bigger key space than a Caesar cipher with 25 keys. The test should be bigger > caesar.
Question 3
A alphabet = 26
B keys = alphabet - 1
C tried = 0
D while tried > keys:
E tried = tried + 1
Line D — The loop should keep trying keys while tried is less than keys. With > it never runs, so no keys are tried. It should be while tried < keys:
Question 4
A text = 'KHOOR'
B for key in range(1, 25):
C print(key, dec(text, key))
Line B — range() stops before its end value, so range(1, 25) only tries keys 1 to 24 and misses key 25. To try all 25 keys use range(1, 26).
Question 5
A caesar == 25
B other = 1000000
C print(other > caesar)
Line A — A single = assigns a value to the variable. == compares two values, so caesar would be undefined. It should be caesar = 25.

Student with a class code? Join your class →