Mythic wrote: ↑Wed Mar 15, 2023 5:48 pm
Hello, I was wondering if someone could explain how you solve the Cryptanalysis of an Affine.
Here's a worked example for you. You are given the cyphertext
"ABOBRFLYBMLHGQBPSLYLSSRYBTODGWLYLQDFRF", and told that the first two letters of the plaintext are H and E.
So you know that under the affine encryption, E(4) -> B(1) and H(7) ->A (0).
So (4a + b) mod 26 = 1
and (7a + b) mod 26 = 0
Subtracting these, you get 3a mod 26 = -1 = 25.
So we're hunting for a value of a for which 3a mod 26 = 25.
3a = 25 is no good, 'cause a needs to be an integer.
3a = 51 gives a = 17, which is a viable solution.
3a = 77 doesn't have an integer solution, and then there aren't any other valid solutions, because you know a<26.
So with a=17, the first equation becomes
(68 + b) mod 26 = 1
or equivalently
(16 + b) mod 26 = 1
And so b = 11.
Now you have determined a and b, you can compute the mappings.
A(0) -> (b mod 26) = 11 = L
B(1) -> (a + b) mod 26 = 2 = C
C(2) -> (2a + b) mod 26 = 19 = T
D(3) -> (3a + b) mod 26 = 10 = K.
And so on.
You might prefer to compute the mappings for the high frequency letters (etaoin shrdlu...) rather than doing them in alphabetical order. Finishing this off is left as an exercise for the reader
