← ACARA Digital Technologies Years 7–8

Decrypting a message with a Caesar shift

To decrypt a Caesar ciphertext, move each letter back along the alphabet by the key number to get the plaintext. A wraps back to Z. Then check the result is a real message.

Understanding Decrypting a message with a Caesar shift in ACARA Digital Technologies Years 7–8

What it does: Subtracting the key moves each letter back. The mod 26 makes it wrap from A back to Z. FCJJM is not a real word, so key 5 is wrong. Key 3 gives HELLO, which is a real message. Encrypting shifts letters forward by the key. Decrypting does the opposite and shifts them back by the key. Back 5 from D goes C, B, A, then wraps to Z, then Y. I is what you get by going forward 5. When you go back past A you wrap round to the end of the alphabet at Z. Decryption is the reverse of encryption, so the shift must go backwards.

Common mistakes: Decrypting a Caesar cipher moves each letter BACK along the alphabet by the key. Moving forward is what encryption does. It should be direction = 'back'. This adds the key, which moves the letter forward and re-encrypts it. To decrypt you subtract the key: n = (n - key) % 26.

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 674–695) and word search (Modules 635–695).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A message was encrypted with a Caesar shift of 3. To decrypt it, which way do you move each letter?
Back 3 places along the alphabetForward 3 places along the alphabet
Matches
KHOOR with key 3 -> NKRRU
↓
The letters were moved forward by 3, which is how you encrypt. To decrypt, move each letter back by 3 to get HELLO.
Applying
Meanings
Term
shift back by key
Meaning
To decrypt a Caesar ciphertext, move each letter back along the alphabet by the key number to get the plaintext. A wraps back to Z. Then check the result is a real message.
Practice
key ← 3
Testing
Gaps
plainNum ← cipherNum -
Check Answer
Spots
1direction = 'forward'
2key = 3

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

The 'Snow Leopard' badge — Silent Debugger, 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. A message was encrypted with a Caesar shift of 3. To decrypt it, which way do you move each letter?
A. Forward 3 places along the alphabet
B. Back 3 places along the alphabet ✓
Encrypting shifts letters forward by the key. Decrypting does the opposite and shifts them back by the key.
2. The key is 1. What is the plaintext letter for the ciphertext letter C?
A. B ✓
B. D
Move back 1 place from C and you land on B. Moving forward to D would be encrypting again, not decrypting.
3. The key is 1. What is the plaintext letter for the ciphertext letter A?
A. Z ✓
B. B
There is no letter before A, so the alphabet wraps around. Going back 1 from A takes you to Z.
4. Decrypt KHOOR with a key of 3. Which plaintext is correct?
A. NKRRU
B. HELLO ✓
Move each letter back 3: K to H, H to E, O to L, O to L, R to O. NKRRU comes from shifting forward by mistake.
5. The key is 5. What is the plaintext letter for the ciphertext letter D?
A. Y ✓
B. I
Back 5 from D goes C, B, A, then wraps to Z, then Y. I is what you get by going forward 5.

Match the Pairs

K shifted back 3 = H → Decrypting: move the ciphertext letter K three places back along the alphabet to get the plaintext letter H.
B shifted back 3 = Y → Wrapping from A back to Z: B goes back to A, then Z, then Y.
To decrypt, subtract the key from each letter's position and wrap around the 26 letters → plain = (cipher - key) mod 26
Check that the result is a real message, because a wrong key gives nonsense → KHOOR with key 5 = FCJJM (nonsense)
KHOOR with key 3 -> NKRRU → The letters were moved forward by 3, which is how you encrypt. To decrypt, move each letter back by 3 to get HELLO.
A shifted back 1 -> no letter, stop → The shift did not wrap around. Going back 1 from A wraps to Z.

Key Term

shift back by key
To decrypt a Caesar ciphertext, move each letter back along the alphabet by the key number to get the plaintext. A wraps back to Z. Then check the result is a real message.

Fill in the Blanks

1. plainNum ← cipherNum - key
Hint: Type the variable holding the number of places to move back along the alphabet.
2. plainNum ← (cipherNum - key) MOD 26
Hint: Type the keyword for the remainder operation that wraps A back round to Z.
3. FOR EACH letter IN ciphertext pos ← position(letter) - key
Hint: Type the name of the variable holding the encrypted message being decrypted.
4. IF plaintext is a real message THEN OUTPUT plaintext ELSE try another key
Hint: Type the keyword for the branch that runs when the check fails.
5. num = ord(letter) - 65 plain = (num - key) % 26
Hint: Type the number of letters in the alphabet, used for wrapping around.

Spot the Error

Question 1
A direction = 'forward'
B key = 3
C cipher = 'KHOOR'
D print(decrypt(cipher, key))
Line A — Decrypting a Caesar cipher moves each letter BACK along the alphabet by the key. Moving forward is what encryption does. It should be direction = 'back'.
Question 2
A def decrypt_letter(c, key):
B n = ord(c) - 65
C n = (n + key) % 26
D return chr(n + 65)
Line C — This adds the key, which moves the letter forward and re-encrypts it. To decrypt you subtract the key: n = (n - key) % 26.
Question 3
A n = (0 - 3) % 25
B print(n)
C print(chr(n + 65))
Line A — The alphabet has 26 letters, so wrapping must use % 26. With % 26, shifting A back 3 gives 23, which is X. Using 25 gives the wrong letter.
Question 4
A cipher = 'KHOOR'
B key = 3
C plain = ''
D for c in plain:
E n = (ord(c)-65-key) % 26
F plain += chr(n + 65)
Line D — The loop must go through each letter of the ciphertext. plain is empty at this point, so nothing would be decrypted. It should be for c in cipher:.
Question 5
A plain = decrypt(cipher, key)
B if plain == cipher:
C print('Key found')
D else:
E print('Try another key')
Line B — After decrypting you must check that the result is a real message that makes sense. Comparing it with the ciphertext does not test that. It should be if plain makes sense:.

Student with a class code? Join your class →