Files
lab_encryption/caesar_cracker.py
mdecker62 4d08a0d4fa d
2026-03-12 15:01:40 -04:00

13 lines
310 B
Python

from collections import Counter
def crack_caesar(ciphertext):
counts = Counter(ciphertext.upper())
most_common_letter = counts.most_common(1)[0][0]
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
shift = (alphabet.index(most_common_letter) - alphabet.index("E")) % 26
return shift