diff --git a/caesar_cracker.py b/caesar_cracker.py new file mode 100644 index 0000000..471ee8c --- /dev/null +++ b/caesar_cracker.py @@ -0,0 +1,13 @@ +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 \ No newline at end of file