I mentioned on Twitter that I’d been teaching Amy (now six) about simple ciphers, and @lucasjosh asked how I went about it. The answer is way too long for Twitter, and probably of more general interest, so I’ll try to explain.

For a while now, Amy has been fascinated by two ideas: other languages (counting to twelve in Spanish as fast as she can) and writing things instead of speaking (writing notes for me and Cindy). These both have to do with alternate means of communication, so I think it’s a natural and common kind of curiosity. I don’t exactly remember where she first encountered the idea of simple letter-to-number substitution (A=1, B=2, …, Z=26) but it was a while ago. It might have come up again in an issue of Highlights that I picked up at the library for her, or maybe even on a kids’ placemat at Friendly’s. In any case, she was the one who suggested that we write some coded messages. After doing some simple ones at first – “I love mommy” and “daddy is a geek” – I let on that there were many more kinds of codes possible. First I used a simple code based on going around the “circle” of letters by mutually-prime seven: 1=A, 2=H, 3=O, and so on. I didn’t actually explain how the table was generated; to her it was just a simple lookup. At this point Cindy made the point that breaking a code is harder when you only have a little bit of text, so we gave her the table. Amy seemed to enjoy that, so I decided to take it a step further and explained that codes could involve reordering as well as substitution. I did this with a simple 4×4 square, with the message written across.

d a d d
y (space) i s
(space) a (space) g
e e k !

Then I showed her how to read down the columns instead of across the rows, so the result is:


So far, so good. Finally, I showed her how you could reverse the process to decode, and just for extra fun how you could repeat the process and end up where you started (giving her an early exposure to matrix operations as well). She thought that was great, and gave the message to Cindy who decoded it quite quickly. For the second one, I used a 6×2 matrix, and challenged Cindy (who had heard the original message) to figure out what size matrix I’d used. I don’t think the idea of the matrix configuration effectively being the key really sunk in, but I think I’ll be able to demonstrate that pretty well when I show her the closely related Caesar cipher.

At that point it was bed time, so Amy and I headed upstairs. The coolest part of the whole thing, though, was that Amy insisted I get her up at 7am sharp (usually Cindy does that while I get ready for work) so we could do some more codes. Awesome.