When I was a kid of about 10, one of my favourite books was Usborne’s Spy’s Guidebook. (I also liked its sister the Detective’s Handbook, but the Spy’s Guidebook always seemed a smidge cooler to me).
So I was pleased when our eldest, now 7, took an interest in the book too. This morning, for example, she came to breakfast with an encrypted message for me (along with the relevant page in the book that contained the cipher I’d need to decode it).
Later, as we used the experience to talk about some of the easier practical attacks against this simple substitution cipher (letter frequency analysis, and known-plaintext attacks… I haven’t gotten on to the issue of its miniscule keyspace yet!), she asked me to make a pocket version of the code card as described in the book.
While I was eating leftover curry for lunch with one hand and producing a nice printable, foldable pocket card for her (which you can download here if you like) with the other, I realised something. There are likely to be a lot more messages in my future that are protected by this substitution cipher, so I might as well preempt them by implementing a computerised encoder/decoder right away.
So naturally, I did. It’s at danq.dev/spy-pocket-code and all the source code is available to do with as you please.
If you’ve got kids of the right kind of age, I highly recommend picking up a copy of the Spy’s Guidebook (and possibly the Detective’s Handbook). Either use it as a vehicle to talk about codes and maths, like I have… or let them believe it’s secure while you know you can break it, like we did with Enigma machines after WWII. Either way, they eventually learn a valuable lesson about cryptography.
Maybe it’s silly to criticize the security, but they could have chosen a better 12 permutations for the system. For instance, keys 3-4 and 6-7 only differ at 6 positions. Better to choose starting positions so that fewer pairs are shared between keys (e.g. starting at 1/I/4/N/7/S/0/X seems better, although I haven’t done a thorough analysis).
Are you sure that flipping on the short edge is correct in your PDF? In the book it looks like the back of the sheet is supposed to be upside-down (so that it can be folded to show 1-6)