← ACARA Digital Technologies Years 7–8

Transposition cipher

A cipher that keeps the same letters but rearranges their order by a rule, like writing them in a zigzag on two rails and reading off the rows.

Understanding Transposition cipher in ACARA Digital Technologies Years 7–8

What it does: DFNEED uses exactly the same letters as DEFEND (D, E, F, E, N, D), only rearranged by the rail fence rule. The top row HLO is followed by the bottom row EL, which gives the ciphertext HLOEL. The letters C, A and T are all still there. Only their positions changed, so it is transposition. The first letter goes on the top rail, the second on the bottom, the third on top again, and so on. Reading the rows one after the other gives the ciphertext. Reading the zigzag order again would just give back the plaintext. With an odd number of letters, the top rail gets one extra. The top rail holds H, L, O and the bottom rail holds E, L.

Common mistakes: The bottom rail of a two-rail rail fence holds the letters at positions 1, 3, 5... so the slice must start at 1: text[1::2]. Starting at 2 skips a letter and repeats letters from the top rail. The ciphertext is made by reading off the top rail and then the bottom rail. The line should be cipher = top + bottom. Using top twice loses the bottom letters.

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 696–726) and word search (Modules 696–770).

Take this worksheet further — free with Cloodit

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

Learning
Duo
What does a transposition cipher change about a message?
The order of the lettersThe letters, swapped for different ones
Matches
ATTACK -> DWWDFN
↓
The letters were changed by shifting them, which is a Caesar (substitution) cipher. A transposition cipher keeps the same letters and only changes their order.
Applying
Meanings
Term
transposition cipher
Meaning
A cipher that keeps the same letters but rearranges their order by a rule, like writing them in a zigzag on two rails and reading off the rows.
Practice
plaintext <- "HELLOWORLD"
Testing
Gaps
rail1 = text[::2]
Check Answer
Spots
2top = text[0::2]
3bottom = text[2::2]

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. What does a transposition cipher change about a message?
A. The order of the letters ✓
B. The letters, swapped for different ones
A transposition cipher keeps the same letters and only rearranges their order by a rule.
2. A cipher turns CAT into ACT. Which type of cipher is this?
A. Substitution: letters replaced with others
B. Transposition: the same letters, rearranged ✓
The letters C, A and T are all still there. Only their positions changed, so it is transposition.
3. How do you write a message on a rail fence with two rails?
A. Zigzag, alternating between the top rail and the bottom rail ✓
B. Write every letter on the top rail, then copy them to the bottom
The first letter goes on the top rail, the second on the bottom, the third on top again, and so on.
4. Using two rails, how do you read off the ciphertext?
A. Read down each column, one pair of letters at a time
B. Read the whole top row, then the whole bottom row ✓
Reading the rows one after the other gives the ciphertext. Reading the zigzag order again would just give back the plaintext.
5. Encrypt HELLO with a two-rail rail fence. What is the ciphertext?
A. HLOEL ✓
B. ELHLO
Top rail: H, L, O. Bottom rail: E, L. Read the top row first, then the bottom row, to get HLOEL.

Match the Pairs

HELLO -> HLOEL → Rail fence with two rails: letters 1, 3 and 5 go on the top rail, letters 2 and 4 on the bottom rail. Reading the top row then the bottom row gives HLOEL.
Top: A T C Bottom: T A K → A grid for ATTACK on two rails. Reading the rows one after the other gives the ciphertext ATCTAK.
A transposition cipher keeps the same letters, so the ciphertext is just the plaintext letters in a new order. → DEFEND -> DFNEED
To read off the rows, join the top rail and then the bottom rail to make the ciphertext. → Top: H L O Bottom: E L -> HLOEL
ATTACK -> DWWDFN → The letters were changed by shifting them, which is a Caesar (substitution) cipher. A transposition cipher keeps the same letters and only changes their order.
Top: H E O Bottom: L L → The first three letters were put on the top rail. In a zigzag the letters alternate between the rails, so the top should be H L O and the bottom E L.

Key Term

transposition cipher
A cipher that keeps the same letters but rearranges their order by a rule, like writing them in a zigzag on two rails and reading off the rows.

Fill in the Blanks

1. text = "HELLO" rail1 = text[0::2] rail2 = text[1::2]
Hint: Type the index of the first letter, where the top rail of the zigzag starts.
2. text = "HELLO" rail1 = text[0::2] rail2 = text[1::2]
Hint: Type the step size, which is the number of rails taking turns.
3. rail1 = "HLO" rail2 = "EL" cipher = rail1 + rail2
Hint: Type the operator that joins the two rows into one string when reading them off.
4. half = (len(cipher) + 1) // 2 rail1 = cipher[:half] rail2 = cipher[half:]
Hint: Type the variable name that marks where the first row ends, so the cipher can be split back into rows.
5. plain = "HELLO" cipher = "HLOEL" print(sorted(plain) == sorted(cipher))
Hint: Type the comparison operator that checks the two sorted letter lists are the same, because a transposition cipher keeps the same letters.

Spot the Error

Question 1
A text = "ATTACK"
B top = text[0::2]
C bottom = text[2::2]
D print(top + bottom)
Line C — The bottom rail of a two-rail rail fence holds the letters at positions 1, 3, 5... so the slice must start at 1: text[1::2]. Starting at 2 skips a letter and repeats letters from the top rail.
Question 2
A plain = "HELLOWORLD"
B top = plain[0::2]
C bottom = plain[1::2]
D cipher = top + top
E print(cipher)
Line D — The ciphertext is made by reading off the top rail and then the bottom rail. The line should be cipher = top + bottom. Using top twice loses the bottom letters.
Question 3
A text = "MEETATNOON"
B rails = 2
C top = text[0::3]
D bottom = text[1::rails]
Line C — A rail fence with two rails takes every 2nd letter, so the step must be 2 (rails). A step of 3 would split the message across three rails and skip letters.
Question 4
A cipher = "ATCTAK"
B half = len(cipher) * 2
C top = cipher[:half]
D bottom = cipher[half:]
Line B — To decrypt, the ciphertext is split in half to get the two rails back. The halfway point is len(cipher) // 2. Multiplying by 2 gives a number bigger than the message.
Question 5
A msg = "SENDHELP"
B row1 = msg[0:2]
C row2 = msg[1::2]
D print(row1 + row2)
Line B — Row 1 should hold every second letter starting at the first letter, so it needs the step: msg[0::2]. msg[0:2] only gives the first two letters, so the letters are not rearranged properly.

Student with a class code? Join your class →