Page 6 of 6

Re: Codebusters B/C

Posted: March 22nd, 2023, 9:37 am
by Sorrow2
Is there any codebusters book that you guys can recommend? I love to read. Thank you in advance!

Re: Codebusters B/C

Posted: March 24th, 2023, 2:20 pm
by Umaroth
Sorrow2 wrote: March 22nd, 2023, 9:37 am Is there any codebusters book that you guys can recommend? I love to read. Thank you in advance!
If you're reading to get better at the event, there won't be anything like that to help since this event is pretty much entirely practice-based

Re: Codebusters B/C

Posted: March 27th, 2023, 2:25 pm
by Mythic
knightmoves wrote: March 16th, 2023, 10:28 am
Mythic wrote: March 15th, 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 ;)
Thanks for the idea but I was wondering how you went from (68 + b) mod 26 = 1 --> (16 + b) mod 26 = 1

Re: Codebusters B/C

Posted: March 27th, 2023, 2:56 pm
by Mythic
Mythic wrote: March 27th, 2023, 2:25 pm
knightmoves wrote: March 16th, 2023, 10:28 am
Mythic wrote: March 15th, 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 ;)
Thanks for the idea but I was wondering how you went from (68 + b) mod 26 = 1 --> (16 + b) mod 26 = 1
I now understand this 😂 but I can't solve this question.

Decode this sentence which has been encoded with an Affine cipher that starts with TH
MWFPF IRXP, RKK DF WFRS ROBJM TP MWRM MWF TEIJPMSX. TP TE MSBJOKF. FGFSXOBIX TP PB PLRSFI, OJM BJS HTPPTBE PMRMFHFEM TP WRGTEZ EB CFRS.

Could you please help me solve this question?

Re: Codebusters B/C

Posted: March 27th, 2023, 6:57 pm
by knightmoves
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".

Re: Codebusters B/C

Posted: March 27th, 2023, 8:00 pm
by Mythic
knightmoves 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".
OMG Thanks I stopped at 10 I didn't realize I had to go further. Thanks again :)

Re: Codebusters B/C

Posted: March 28th, 2023, 6:03 am
by Sorrow2
knightmoves wrote: March 16th, 2023, 10:28 am
Mythic wrote: March 15th, 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 ;)
Affine Cipher looks confusing ;-;

Re: Codebusters B/C

Posted: March 28th, 2023, 7:24 am
by knightmoves
Sorrow2 wrote: March 28th, 2023, 6:03 am Affine Cipher looks confusing ;-;
;)

Modular arithmetic takes a bit of getting used to. Once that makes sense, the affine cypher really isn't too bad. This is cryptanalysis of the affine cypher, which is the most complicated affine problem you might see, and even then, it's an almost completely mechanical process. There's no guessing letter combinations required: it's a small amount of arithmetic, plus a large amount of turning the handle.

Re: Codebusters B/C

Posted: April 5th, 2023, 6:17 pm
by Mythic
Hi, quick question on Fractionated Morse does it always end in X or XX or does it vary?

Re: Codebusters B/C

Posted: April 6th, 2023, 12:21 pm
by knightmoves
Mythic wrote: April 5th, 2023, 6:17 pm Hi, quick question on Fractionated Morse does it always end in X or XX or does it vary?
https://www.soinc.org/relating-fraction ... end-mark-0