// Program to decrypt an interesting encipherment technique by Duncan McKenzie. key = [["A", "B", "C", "D", "E", "F"], ["F", "H", "I", "J", "K", "L"], ["M", "N", "O", "P", "Q", "R"], ["S", "T", "U", "V", "W", "X"], ["Y", "Z", " ", "?", ",", "."]] text = """I like your new punctuation cipher - the one using those higher Unicode values - but I was thinking something simpler. What I have in mind is easy to explain, and relatively fast - a system humans can use without a computer - in fact, enciphering can be much easier for humans than computers. I am using it here - I have no difficulty expressing my own ideas, but even so, this email manages to embed a buried message without appearing suspicious. So, I will now reveal my wonderful system. Very simply, it depends on the number of words between punctuation. You take these numbers, then decode them on an ordinary grid. It works well, and the numbers I chose provide some protection against coding errors. Better still, the system works as well with emails as handwritten messages. Just below, I have pasted the grid for decrypting messages. Maybe Frink can do this, although it is not laborious by hand. All punctuation counts - but I was not sure about apostrophes and therefore avoided them. On consideration, it would probably be useful to leave apostrophes out. Clearly, this would add a certain flexibility in modifying word counts. However, it adds to the number of rules. For now then, I am trying fastidiously to avoid the use of any apostrophes. When converting plaintext to paragraphs, the most important trick is to keep paraphrasing your words, adjusting each block, so that the number of words is correct. This sounds like it is hard, but the human brain does it fairly easily. To do this on a computer, it would be easier to use prepared sentences, or sentence chunks, rather than attempting to understand and then paraphrase a custom message. Another point - a minor detail that I quite like - my grid system includes spaces. I think the resulting text looks civilized - or reasonably so - compared to the spaceless jumble produced by many of these ciphers. However, although this system strikes me as fairly novel, I have doubts. Punctuation seems such an obvious way of hiding messages, that I wonder, has this system already been invented and used? I have not read about it, but there are countless variations in cipher systems, not to mention steganography systems, that it might well have been used, or long ago abandoned, without popping up in the cipher books. Let me know what you think. I will be interested to hear your thoughts on this system.""" for [r1, r2] = text =~ %r/([^\-\.,\!\?]+)[\-\.,\!\?]([^\-\.,\!\?]+)/gm { col = length[split[%r/\s+/m, trim[r1]]] - 1 row = length[split[%r/\s+/m, trim[r2]]] - 7 print[key@row@col] }