I have created the code in caesar_cracker.py along with finding the secret numbers for each secret txt that are answered in answers.md.

Developing this code was not the easiest. I did run into some trouble at first with it returning a different secret number from the example in the notes online but then after changing the code and debugging it I got it to return the secret number to be 34. I was able to understand how Caesar Cipher actually works.
This commit is contained in:
erbrown2
2026-05-19 13:39:00 -04:00
parent 52f26bd1ee
commit 4ae218af57
3 changed files with 167 additions and 0 deletions

22
caesar_cracker.py Normal file
View File

@@ -0,0 +1,22 @@
from collections import Counter
from ciphers.caesar import CaesarCipher
from easybits import Bits
class CaesarCracker:
def crack_caesar(self, ciphertext):
freq = Counter(ciphertext)
most_common_cipher_char = freq.most_common(1)[0][0]
space_int = Bits(' ').int
cipher_int = Bits(most_common_cipher_char).int
secret = cipher_int - space_int
return secret
def crack_caesar(ciphertext):
cracker = CaesarCracker()
return cracker.crack_caesar(ciphertext)