4 from szyfrow
.autokey
import *
5 from szyfrow
.support
.utilities
import *
8 def test_encipher_message():
9 enciphered
= autokey_encipher('meetatthefountain', 'kilt')
10 expected
= 'wmpmmxxaeyhbryoca'
11 assert enciphered
== expected
13 def test_decipher_message():
14 deciphered
= autokey_decipher('wmpmmxxaeyhbryoca', 'kilt')
15 expected
= 'meetatthefountain'
16 assert deciphered
== expected
19 # plaintext = '''hours passed during which jerico tried every trick he
20 # could think of to prompt some fresh inspiration. he arranged the
21 # cryptograms chronologically then he arranged them by length. then
22 # he sorted them by frequency. he doodled on the pile of paper. he
23 # prowled around the hut, oblivious now to who was looking at him
25 # # expected_key = 'samplekey'
26 # expected_key = 'abc'
27 # ciphertext = autokey_encipher(sanitise(plaintext), expected_key)
28 # expected_score = Ptrigrams(sanitise(plaintext))
29 # actual_key, actual_score = autokey_sa_break(ciphertext,
30 # min_keylength=len(expected_key), max_keylength=len(expected_key),
31 # workers=10, max_iterations=1000, fitness=Ptrigrams
33 # assert expected_key == actual_key
34 # assert expected_score == pytest.approx(actual_score)