Students send a reversed message, see that anyone who knows the method can undo it, and meet the idea of a public method with a secret key.
Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
Predict and Run 7 min · Investigate 10 min · Modify 6 min · Make 15 min
The idea: a cipher is a method for scrambling a message. If the method is the only secret, everything is lost the moment someone learns it. Real ciphers have a public method and a secret key; Caesar's cipher, next, is the smallest example.
Vocabulary: plain text (before), cipher text (after), method (steps), key (the secret value). Use them every time from now on.
Code: this lesson teaches the code every later cipher is built from. Foundations functions were named jobs with nothing in or out; reverse(text) takes a parameter and returns a text. The for index loop visits each place 0 to length − 1, and text.charAt(i) is the letter at place i (counted from 0, like a list). The Investigate trace task (result after i = 0 and 1) checks students can follow it; spend time here, because Caesar, Checksum and the CTF reuse the same shape.
A method everyone knows hides nothing. Ask what a listener who knows the method would need to read the message.
| What you will see | A question to ask | The fix |
|---|---|---|
| The receiver shows OLLEH. | Where does the receiver undo the reversing? | Show reverse(received string) instead of received string. |
| The text comes out shorter or longer than expected in unscramble. | Which letters does unscramble keep? | Loop i up to half the length, and join the letter at place i × 2. |
One possible solution for each task. Other correct programs are fine.

function reverse(text: string): string {
let result = ""
for (let i = 0; i < text.length; i++) {
result = text.charAt(i) + result
}
return result
}
radio.setGroup(5)
input.onButtonPressed(Button.A, function () {
radio.sendString(reverse("HELLO"))
})
radio.onReceivedString(function (receivedString) {
basic.showString(reverse(receivedString))
})

function scramble(text: string): string {
let result = ""
for (let i = 0; i < text.length; i++) {
result = result + text.charAt(i) + "X"
}
return result
}
function unscramble(text: string): string {
let result = ""
for (let i = 0; i < text.length / 2; i++) {
result = result + text.charAt(i * 2)
}
return result
}
radio.setGroup(5)
input.onButtonPressed(Button.A, function () {
radio.sendString(scramble("MEET AT 3"))
})
radio.onReceivedString(function (receivedString) {
basic.showString(unscramble(receivedString))
})
Stretch: Make the scrambler swap each pair of letters (HELLO → EHLLO).
Support: Give scramble complete and ask only for unscramble.
Why is a message that is scrambled with a method everyone knows not private?
Anyone who knows the method can undo it. A code needs a secret key that is separate from the method.
Next: a code with a key, the Caesar cipher.