File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change
1
+ import math
2
+
1
3
LETTER_FREQUENCIES_DICT = {
2
4
"A" : 8.12 ,
3
5
"B" : 1.49 ,
@@ -216,7 +218,20 @@ def find_key_from_vigenere_cipher(ciphertext: str) -> str:
216
218
# print(key)
217
219
218
220
219
-
220
221
# ---------- TESTS ----------
221
- # 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
222
237
You can’t perform that action at this time.
0 commit comments