Files
lab_encryption/caesar_cracker.py
erbrown2 4ae218af57 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.
2026-05-19 13:39:00 -04:00

23 lines
533 B
Python

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)