Coding is Fun

advertisement
Coding is Fun
Secret Codes : Notes
1.
Preparation: Prepare one “Caesar Wheel” for each pupil. Print out the
blanks; cut out the larger and smaller letter circles; join them together in
the centre with a paper fastener so that the smaller circle (upper case
letters) fits within the letters on the larger circle (lower case letters)
and can be turned.
2.
Introduction: Start by asking pupils whether they know what we mean by
secret codes. How do people send secret messages? Who uses these
codes? Governments, the military and spies. Who else?
3.
Today – everyone! Computers and the internet use them all the time. The
padlock symbol and an httpS: web address (URL or Uniform Resource
Locator) mean messages sent over the internet between the web browser
and the web server are encrypted (encoded using a secret code). Most of
the time, the internet works more like sending post cards – anyone can
read the messages. So anything we want kept secret (like passwords,
bank details etc.) has to be encrypted.
Copyright Tenscope Limited © 2014
Registered in the UK; Company number: 06656008; Registered office : 136 Pinner Road, Northwood, Middlesex, HA6 1BP
See www.codingisfun.co.uk for terms and conditions of use of all resources
4.
We think of sending secret messages like this. Alice wants to send a
message to Bob (traditionally, it always is Alice and Bob!) – but they don’t
want Eve (the traditional Eavesdropper) to be able to read it. So they
decide on a type of cipher (secret code) to use – and agree a (secret) key.
Alice uses the cipher and the key to encipher (encode) the plain text (the
readable message) to produce the cipher text (encoded message), which
she sends to Bob. Bob then uses the cipher and the key to decipher
(decode) the cipher text to get back the plain text.
5.
First activity: a simple example – Caesar Cipher. Get pupils to work in
pairs. Every pupil needs a Caesar Wheel. Walk them through the
following steps to encipher a simple word, like “hello” – and then decipher
the cipher text to get the plain text back again. Then get them to have a
go for themselves.
6.
First, each pair of pupils needs to agree on the key to be used. For the
Caesar Cipher this is just a single letter – for example, ‘D’.
7.
Second, they both need to turn their Caesar Wheels so that the lower
case (small) letter ‘a’ is next to the upper case (capital) ‘D’ (or whatever
other key letter has been agreed upon). It’s a convention in cryptography
(the study of ciphers) that the plain text is always written in lower case
and cipher text in upper case – it helps avoid confusion!
8.
Third, each pupil comes up with a short message (2 or 3 words will do
nicely) and enciphers it using the Caesar Wheel. Take each letter in turn;
find the relevant lower case letter on the wheel; read across (inwards) to
the corresponding upper case letter. So, using ‘D’ as the key, “hello” would
be enciphered as “KHOOR”.
9.
Fourth, exchange cipher text messages with your partner.
10.
Fifth, decipher the cipher text using the Caesar Wheel by reversing the
process. Take each letter in turn; find the relevant upper case letter on
the wheel; read across (outwards) to the corresponding lower case letter.
So, using ‘D’ as the key, “KHOOR” would be deciphered as “hello”.
11.
Is this a good cipher? How many possible keys are there? 26 possible
letters of the alphabet. But ‘A’ doesn’t work. Why not? So only 25
possible keys. When you know how the cipher works, this is very quick and
easy to crack. Amazing that it was ever worth using! Named after Julius
Caesar who did use it!
Copyright Tenscope Limited © 2014
Registered in the UK; Company number: 06656008; Registered office : 136 Pinner Road, Northwood, Middlesex, HA6 1BP
See www.codingisfun.co.uk for terms and conditions of use of all resources
12.
Second Activity: something a bit harder – Substitution Cipher. We don’t
just shift letters on round the alphabet – we muddle them up. So the key
is a jumbled up alphabet.
13. You now need to emphasise that no-one should just call out anything.
If they have anything to say, they need to put their hand up and wait
to be asked. From here on it only takes one person to say something
out loud to spoil the whole session for everyone. Keep repeating this
frequently and don’t tolerate any infringements. For the third
activity, the main point is that every pupil should get there for
themselves!
14.
Give each pupil a copy of the short cipher text and a copy of the
completed key. Work through the first few letters. Take the upper case
letter from the cipher text; find it in the key; read across to the lower
case plain text letter. Get each pupil to work through and decipher the
whole message. When they are done, it might be as well to point out that
you haven’t hidden anything anywhere for them to find (unless, of course,
you have!).
15.
Third Activity: cracking a code! What if you are Eve? How hard is this
substitution cipher to crack?
16.
Give each pupil a copy of the long cipher text and a copy of the blank key.
Emphasise that we do not have the key that was used to encipher this
message. And it is NOT the same key as was used for the last message.
17.
Ask pupils to look at the message closely and come up with ideas of
interesting things about it that might help us (hand up – do not call out!).
If any suggestions come up that I haven’t talked about below, discuss
them (and use them if they are good) but be prepared to move the
discussion on fairly quickly.
18.
First interesting point: single letter word ‘Z’ in the third line. Someone
usually comes up with this fairly quickly. What can it be? ‘a’ or ‘i’ are
obvious possibilities. Other options? What about other languages? Do we
actually know that this is English? Someone’s initial? ‘u’ as in “U-Turn”?
Maybe, but ‘a’ or ‘i’ are more likely. Take a vote on it among the pupils.
They’ll (almost) always end up with ‘a’. Emphasise that this is only an
educated guess. We don’t actually know whether it’s right. We might
have to go back and try something else if it doesn’t work out.
Copyright Tenscope Limited © 2014
Registered in the UK; Company number: 06656008; Registered office : 136 Pinner Road, Northwood, Middlesex, HA6 1BP
See www.codingisfun.co.uk for terms and conditions of use of all resources
19.
So fill in ‘a’ against ‘Z’ in the key. And go through and write ‘a’ under (or
above) every ‘Z’ in the text. This matters. Whatever clues we get, we
need to get as much as we can out of them.
20.
Second interesting point: single letter ‘H’ after an apostrophe in the
fifth line. This is unusual. What sorts of words could we be looking at?
“wasn’t”, “isn’t” etc. Or possessives – “cat’s”, “dog’s” etc. Any others
(slang and colloquialisms maybe but otherwise I’m struggling)? Another
vote – usually ends up with ‘s’. Again, emphasise that this is only a guess –
it might be wrong.
21.
So fill in ‘s’ against ‘H’ in the key. And go through and write ‘s’ under (or
above) every ‘H’ in the text.
22.
Third interesting point: the context of the message.
23.
At this stage, explain that you didn’t make the message up. It came from
the flyer for the annual Alan Turing Cryptography Competition run by
Manchester University. Put the flyer up on a screen / whiteboard if you
can – or pass round copies. There are lots of details about the
competition, how to enter etc. And this message in the middle of it with
no explanation as to why it is there. But presumably it is relevant to the
competition or something else in the flyer in some way.
24.
This gives us a clue about words that might be in the message. Wouldn’t
it be good if we could fit a whole word in? And it’s more helpful to try to
fit longer words than shorter words – 8 or more letters is great. So why
not pick something and see if it fits anywhere? Remember – if something
fits, use it to fill in more of the key – and then use that to fill in letters in
the message. Then see if you can spot anything else that might give you a
clue.
25.
At this stage working in silence is highly desirable!
26.
Watch for those that are struggling – for ideas of long words to try
(gentle nudging is often sufficient) – or with spelling of long words
(encourage them to copy from the flyer).
27.
Some may also need help recognising that if a letter deciphers as, say, ‘I’
in one place, then it must always decipher as ‘I’. And this really helps
decide whether a long word might fit or not.
Copyright Tenscope Limited © 2014
Registered in the UK; Company number: 06656008; Registered office : 136 Pinner Road, Northwood, Middlesex, HA6 1BP
See www.codingisfun.co.uk for terms and conditions of use of all resources
28.
Then it’s often a question of telling pupils to have confidence – try things
– use the key and whatever letters they’ve already guessed. This is partly
being systematic about using the information they have – and partly about
intuition and educated guesswork. Once they’ve successfully fitted in a
long word, most will get there with encouragement.
29.
Some may guess the whole key – even at a very early stage. This is where
not calling out matters. It’s preferable to take a pupil to one side (even
out of the room) and get them to whisper if they have ideas rather than
risking giving the game away.
30.
Don’t be tempted to give out answers if there are still pupils working on it
and likely to make progress. If necessary, wait till the next session.
31.
The key (the alphabet reversed) is actually quite famous. It was used in
the Bible (Jeremiah) in the original Hebrew known as the Atbash Cipher –
named after the first / last letters of the Hebrew alphabet (Aleph / Tav)
and second / last but one (Beth / Shin). As such, other than as a specific
substitution cipher, the Atbash Cipher has no key as such – so is hardly a
cipher at all!
32.
Recap and extension: how did we crack this? Three interesting point.
Did you think this was going to be hard? Was it actually that difficult?
33.
Throughout history, cryptography has been a game. Alice and Bob invent
ciphers to stop Eve cracking them. Eve invents ways to crack the new
ciphers.
34.
Substitution ciphers turned out to be moderately easy to crack. So what
happened next? Alice and Bob stopped putting in the spaces between
words – and the punctuation. So we have no single letter words to attack.
No single letters after apostrophes. And no long words. All 3 ways we
used to get into this message have been removed!
35.
So what did Eve do? What’s the most common letter in English? ‘e’.
Second most common? ‘t’. Then ‘a’, ‘o’, ‘i’, ‘n’ etc. So we can look at how
often letters occur in the cipher text and match this up with how common
letters are in typical English writing. It won’t be perfect. But hopefully
we’ll get enough right to be able to pick out some clues to get us started.
This is called Frequency Analysis.
36.
Does frequency analysis always work? No. One problem with this (and
other techniques) is that we don’t always know what language the plain
text was in. So we might be matching with the wrong pattern of letter
frequencies.
Copyright Tenscope Limited © 2014
Registered in the UK; Company number: 06656008; Registered office : 136 Pinner Road, Northwood, Middlesex, HA6 1BP
See www.codingisfun.co.uk for terms and conditions of use of all resources
37.
Another problem is that we might have an unusual plain text – imagine
what might happen if it was a “quiz about a quiet queen in a quandary over
quick qualification to join the quakers”!
38.
More dramatic was the French novel “La Disparition” by Georges Perec
that does not contain a single letter ‘e’ in the entire text! Or, even more
remarkably, its translation into English by Gilbert Adair entitled “A Void”
– also without a single letter ‘e’. N.B. This certainly isn’t a novel I’d
recommend to primary school pupils and not one that I especially enjoyed
reading myself as an adult. But the fact that it exists at all is sufficient
to merit a place on my bookshelf.
39.
Beyond frequency analysis? Rather a lot – but not this session!
Copyright Tenscope Limited © 2014
Registered in the UK; Company number: 06656008; Registered office : 136 Pinner Road, Northwood, Middlesex, HA6 1BP
See www.codingisfun.co.uk for terms and conditions of use of all resources
Download