generated from mwc/lab_encryption
d
This commit is contained in:
13
caesar_cracker.py
Normal file
13
caesar_cracker.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user