Talking in Riddles R. Ramanujam, The Institute of Mathematical Sciences, Chennai Ifmmp! Ipx bsf zpu upebz? Gibberish? Or am I, perhaps, talking in code? Yes, indeed, this is what is called a cipher text. What is a plain, ordinary, everyday sentence has been converted into this indecipherable, ununderstandable text. But it is not nonsense! Once you figure out how I generated the cipher, you will see what it means, easily. What you need is the key that decodes the cipher text into plain text. This is the inverse of the key I used to do the coding, in the first place. But how can you find the inverse key without knowing the original key? That seems hard, doesn't it? What if I tell you I used a substitution cipher - that is, for each letter of the alphabet, I substituted another, different letter? At this point you should pause and work it out. It should take you only a few minutes to figure it out. Got it? Yes I used the code that maps a - b, b - c, c - d, d - e, and so on, with y - z, z - a. Thus 'Hello' became 'Ifmmp' ! This is a neat trick but you are now perhaps also worried and quite rightly so. If it is so easy to figure out how to break this code, you cannot use it very well to communicate with your friends, can you? Well, the answer is to try a more complicated substitution cipher. How about this? a - d, b - c, c - f, d - e, e - h, f - g, etc. You should try out a few examples and generate texts using this code. What do you find? You see that these cipher texts are not really much harder to break, don't you? So these kinds of linear shifts where the kth letter is mapped to the (km)th letter can be broken easily. How about a random permutation of a to z? Consider this mapping: (a b c d e f g h i j k l m n o p q r s t u v w x y z) - (q g h r x w e l o m z b y p t a v c u d s f k i n j) This is quite a secure code. The sentence we began with is now coded as: Lxbbt! Lti qcx nts dtrqn? This is surely hard to break? But there is one big problem with this code. How can you remember this mapping? You have to write it down somewhere, carry it with you whenever you intend to / expect to use it. Also if you wish to communicate with Kavita using this code, Kavita has to know this code also and she cannot remember it either! But writing it down on a piece of paper and carrying it about is dangerous! If it gets stolen or, even worse, just gets copied by someone (so you don't know the the secret code has been leaked), there is little point in using the code for any secret messages at all. Is it possible to generate a code that looks quite arbitrary and yet is easy to remember? Yes, and such a method has been used for more than two thousand years. It is called the Caesar code, named after the Roman Emperor Julius Caesar. It is based on the simple idea of using key-words to generate codes. Let us say that the key-word is 6 letters long and we make sure that no letter repeats in it. "SMILEY" is a good example. ("BUTTER" is not.) Now we generate the code as follows. Map the letters A to F to SMILEY, and from G onwards, use the first letter that is still available. Of course, some letters may get mapped to themselves but that is alright. (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) - (S M I L E Y A B C D F G H J K N O P Q R T U V W X Z) Now how will you code the first example? BEGGQ! BKV SPE XKT RKLSX? But then decoding is easy. Look at the inverse map: (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) - (G H I J E K L M C N O D B P Q R S T A U V W X Y F Z) Now you can substitute in the cipher text and find the original text. The only information that both you and your friend need to remember is the 6-letter key-word. Easy, isn't it? Try out lots of examples with different key-words. Make up the code using a key-word, and communicate the coded cipher text to a friend. Tell your friend the key-word and see how (s)he decodes it. Key-word based codes are easily implemented. Can one break them as well? Is it easy to come up with a technique that allows us to 'discover' the secret key-word? Send in your ideas, we will see the answer next time.