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 becfd07 commit f1c953dCopy full SHA for f1c953d
1 file changed
ciphers/break_vigenere.py
@@ -1,3 +1,5 @@
1
+import math
2
+
3
LETTER_FREQUENCIES_DICT = {
4
"A": 8.12,
5
"B": 1.49,
@@ -216,7 +218,20 @@ def find_key_from_vigenere_cipher(ciphertext: str) -> str:
216
218
# print(key)
217
219
220
-
221
# ---------- TESTS ----------
-# def test_index_of_coincidence(f)
222
223
+class Test:
224
+ def test_index_of_coincidence(self):
225
+ ic = index_of_coincidence({'a': 50, 'b': 50}, 50)
226
+ assert math.isclose(ic, 2.0)
227
228
+ def test_calculate_indexes_of_coincidence(self):
229
+ ciphertext = "hellothere"
230
+ result = calculate_indexes_of_coincidence(ciphertext, 2)
231
+ assert result == [0.1, 0.3]
232
233
+ def test_friedman_method(self):
234
+ ciphertext = "asqsfdybpypvhftnboexqumfsnglmcstyefv"
235
+ result = friedman_method(ciphertext, 5)
236
+ assert result == 3
237
0 commit comments