Last week we learned how to encode affine ciphers. This week we learn to decode.
In affine ciphers the decryption function for a letter denoted by x is
d(x) = a-1(x - b) mod m
First of all, we need to understand a few rules:
- m is the size of the alphabet - in English it's 26
- b is in the range (0,m-1)
So, we know that in the equation:
d(which, in this case, stands for decrypt)(x) = a-1(x - b)(mod 26)
Next, let's find 'a-1'.
I'm not going to explain how to find the inverse to a number (it's a long complicated process - however, if anyone does have a question about this, I will be happy to send you the answer in an email) but for 'a' with {1,3,5,7,9,11,15,17,19,21,23,25} the inverse 'a-1 is {1,9,21,15,3,19,7,23,11,5,17,25}.
Here's an example:
Lets use (5,8) that means a=5 and b=8. However, the inverse of 5 is 21.
| ciphertext: | I | H | H | W | V | V | C | S | W | F | R | C | P |
| y: | 8 | 7 | 7 | 22 | 21 | 21 | 2 | 18 | 22 | 5 | 17 | 2 | 15 |
| ciphertext: | I | H | H | W | V | C | S | W | F | R | C | P |
| y: | 8 | 7 | 7 | 22 | 21 | 2 | 18 | 22 | 5 | 17 | 2 | 15 |
| 21(y-8): | 0 | -21 | -21 | 294 | 273 | -126 | 210 | 294 | -63 | 189 | -126 | 147 |
| (21(y-8)) mod 26: | 0 | 5 | 5 | 8 | 13 | 4 | 2 | 8 | 15 | 7 | 4 | 17 |
| ciphertext: | I | H | H | W | V | C | S | W | F | R | C | P |
| y: | 8 | 7 | 7 | 22 | 21 | 2 | 18 | 22 | 5 | 17 | 2 | 15 |
| 21(y-8): | 0 | -21 | -21 | 294 | 273 | -126 | 210 | 294 | -63 | -126 | 147 | |
| (21(y-8)) mod 26: | 0 | 5 | 5 | 8 | 13 | 4 | 2 | 8 | 15 | 7 | 4 | 17 |
| plaintext: | A | F | F | I | N | E | C | I | P | H | E | R |
Now your turn:
Decode this with the decryption key (a,b) = (7,5) with the inverse of a being (15,5) and ignore the capitals, spaces and question mark:
Gfi rzpubheo zs ich mftx!
(I will post the answer next week!)
Example source: Wikipedia
Picture source: Woot.com
Now I know it's time for me to go to bed...
ReplyDeleteHi Clarissa .. this is really testing .. and even though I have coffee - I'm not up to it!
ReplyDeleteVery interesting to read about though .. thanks for giving us an insight ..
PS decoding the A - Z Challenge is more up my street at the moment?! .. cheers Hilary
huh now? Unfortunately there are only pirates swashbuckling and dragons flying in my head - I would suck at playing Nancy Drew :-)
ReplyDeleteWow my eyes are buggin'. lol... but I love this kind of stuff. Hmm.. I'll have to get back to you on this...
ReplyDeleteClarissa - I find this utterly fascinating and I have so much admiration for people who can create and break codes. I wish I could but my brain just doesn't think that way. I'm going to have to really "chew" on this one...
ReplyDeleteMy head, my beautiful head (with its one brain cell...!).
ReplyDeleteTake care
x
This is one that will take some time (and several more cups of coffee) to understand. You amaze me with your many talents. Interesting post.
ReplyDeleteMason
Thoughts in Progress
OK...I still understand absolutely nothing about this code. Zero. But I love it. And I like the pi|pie graphic :)
ReplyDeleteI think I'm failing this math exam ....
ReplyDeleteWow, there's like way too many numbers here, LOL! ;)-
ReplyDeleteTaz fp D ovdsx kadh? I don't understand....and I thought I was doing it so well! ;)
ReplyDeleteWow, this is interesting! I need to return when I've got a bit more time to figure this out. And who said math wouldn't come in handy? :)
ReplyDeleteIntriguing, but wow ...
ReplyDeleteI enjoyed reading about this.
That's complicated but fascinating code!
ReplyDeleteWhew...you were blessed with this ability, but I fear I wasn't! Simple code, yes. Complex code, I want my mommy!
ReplyDelete