Checkpoint 2:

This was a much more difficult process, which makes sense because the
encryption itself is harder too. Here is my process...
1. I started by trying to write the code that would eliminate possibilities
for the possible secret word. That created a pattern that was incorrect and repeated.

2. So, my next step was to refine the code so it identified the pattern and would stop the
word when it recognized the pattern hopefully creating one word rather than a pattern. This worked to isolate the pattern, but the
code for the secret word was still incorrect.

3. I looked up what the secret word would be and tried to create a code that asked
for the correct number of characters and tried to call it again, and that did
not work either.

4. So, finally I went back to my first solution and it worked better! But it
was still not perfect. However, I was able to figure out the secret message of
The gold is hidden inside the old fireplace upstairs in the cabin.
This commit is contained in:
Rebecca Hankey 2025-04-16 13:24:23 -04:00
parent d9b142d8ad
commit 7dfe2e3970
2 changed files with 36 additions and 1 deletions

View File

@ -21,7 +21,9 @@
## Checkpoint 2
5. What is the polyalphabetic secret word?
5. What is the polyalphabetic secret word? secretword
6. Decrypt this message, which was encrypted using the same secret word:
"EbZhdaV[h^bTpchhQnhig]X[VmhhRP]ftXVnRfjVY]fgtO_X]("
The gold is hidden inside the old fireplace upstairs in the cabin.

33
crack_poly.py Normal file
View File

@ -0,0 +1,33 @@
from ciphers.poly import PolyCipher
def crack_poly_secret(plaintext, ciphertext):
if len(plaintext) != len(ciphertext):
print("Must be same length")
return None
shift_values = []
for i in range(len(plaintext)):
plain_char = plaintext[i]
cipher_char = ciphertext[i]
shift = (ord(cipher_char) - ord(plain_char)) % 128
shift_values.append(shift)
secret_candidate = ''.join(chr(s) for s in shift_values)
for size in range(1, len(secret_candidate)):
pattern = secret_candidate[:size]
repeated = (pattern * ((len(secret_candidate) // size) + 1))[:len(secret_candidate)]
if repeated == secret_candidate:
return pattern
return secret_candidate