We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 851fc3e commit 6134fa1Copy full SHA for 6134fa1
ciphers/break_vigenere.py
@@ -8,6 +8,19 @@
8
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
9
10
11
+def index_of_coincidence(frequencies: dict, length: int) -> float:
12
+ """
13
+ Calculates the index of coincidence for a text.
14
+ :param frequencies: dictionary of the form {letter_of_the_alphabet: amount of times it appears in the text as a percentage}
15
+ :param length: the length of the text
16
+ :return the index of coincidence:
17
18
+ index = 0.0
19
+ for value in frequencies.values():
20
+ index += (value/length)**2
21
+ return index
22
+
23
24
def find_key_from_vigenere_cipher(ciphertext: str) -> str:
25
clean_ciphertext = list()
26
for symbol in ciphertext:
requirements.txt
0 commit comments