generated from mwc/lab_encryption
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!
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user