Re: Codebusters B/C
Posted: March 22nd, 2023, 9:37 am
Is there any codebusters book that you guys can recommend? I love to read. Thank you in advance!
Thanks for the idea but I was wondering how you went from (68 + b) mod 26 = 1 --> (16 + b) mod 26 = 1knightmoves wrote: ↑March 16th, 2023, 10:28 amHere'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![]()
I now understand thisMythic wrote: ↑March 27th, 2023, 2:25 pmThanks for the idea but I was wondering how you went from (68 + b) mod 26 = 1 --> (16 + b) mod 26 = 1knightmoves wrote: ↑March 16th, 2023, 10:28 amHere'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![]()
OMG Thanks I stopped at 10 I didn't realize I had to go further. Thanks againknightmoves wrote: ↑March 27th, 2023, 6:57 pm Same principle. You know T(19) -> M(12)and H(7) -> W (22)
So (19a + b) mod 26 = 12
and (7a + b) mod 26 = 22
Subtract to get
12a mod 26 = (-10) = 16 [-10 is 16 because we're doing arithmetic in mod 26]
Now hunt for a solution
12a = 16 is no good (16/12 has remainder 4)
12a = 42 is no good (42/12 has remainder 6)
12a = 68 is no good (68/12 has remainder 8)
you can see the pattern now, right? we're going to want
12a = 120 -> a = 10
Are there other possibilities?
12a = 146 is no good (146/12 has remainder 2)
12a = 172 is no good (172/12 has remainder 4)
...
12a = 276 -> a = 23
So either a = 10 or a = 23.
If a = 10, (70 + b) mod 26 = 22
so b=4
If a = 23, (161+b)mod26 = 22
so (5+b) = 22
b = 17.
So you have two possibilities = (a,b) = (10,4) or (23,17).
But a=10 isn't a viable solution (10 is not coprime with 26), so (a,b) = (23,17) is the only possible solution.
Now you have a and b, you can build the mapping table as before.
Clue: the answer begins "THESE DAYS, ALL WE HEAR ABOUT".
Affine Cipher looks confusing ;-;knightmoves wrote: ↑March 16th, 2023, 10:28 amHere'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![]()