From 4fc2cfe227aa2f8a5052ed874139dcdc32d657d7 Mon Sep 17 00:00:00 2001 From: zoeyande2 Date: Tue, 31 Mar 2026 19:29:44 -0400 Subject: [PATCH] Finished checkpoint 2 1. Writing my own code definitely helped me understand the problem better. It was kind of lucky that the most common character in each of the secret texts was in fact " ". It made me understand the work that the cipher is doing better. 2. I watched like 3 different youtube videos about the Kasiski examination process after reading the wiki page. I quickly used "the" to get a difference to the next "the" that mapped the same as 42, so I knew the keyword had to be a multiple of 2,3, or 7. I tried the process with 3 and got nowhere, so I tried it with 6 on a whim. I got the first two letters of the code to be PY, then I couldn't figure out the third so I skipped it, and got the 4th letter to be H, so I made the guess that the keyword was PYTHON and I was right! --- answers.md | 4 ++++ caesar_cracker.py | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/answers.md b/answers.md index 45933f3..1e6fab3 100644 --- a/answers.md +++ b/answers.md @@ -31,5 +31,9 @@ 5. What is the polyalphabetic secret word? +PYTHON (this literally took me so long but it was also so fun omg) + 6. Decrypt this message, which was encrypted using the same secret word: "EbZhdaV[h^bTpchhQnhig]X[VmhhRP]ftXVnRfjVY]fgtO_X](" + +'The treasure is a worthless ball of aluminum foil.' (anticlimatic, lol) \ No newline at end of file diff --git a/caesar_cracker.py b/caesar_cracker.py index 0d5dcda..bdc2f7f 100644 --- a/caesar_cracker.py +++ b/caesar_cracker.py @@ -22,10 +22,27 @@ def crack_caesar(ciphertext): target = char diff = Bits(target,8).int - Bits(" ",8).int + cipher = CaesarCipher(diff) - decryptedtext = cipher.decrypt(fulltext) + decryptedtext = cipher.decrypt(fulltext) #I included this part to double check that the function works return diff, decryptedtext +def polyalpha_helper(text): #used to help crack the code! + groups = [[],[],[],[],[],[]] + for i in range(len(text)): + for n in range(6): + if i%6 == n: + groups[n].append(text[i]) + + groupmax = [] + + for alist in groups: + counter = dict(Counter(alist)) + sorter = sorted(counter.items(), key=lambda item: item[1], reverse = True) + max = sorter[0] + groupmax.append(max) + + print(groupmax)