9 jupytext_version: 1.3.4
11 display_name: Python 3
18 currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
19 parentdir = os.path.dirname(currentdir)
20 sys.path.insert(0,parentdir)
24 from cipher.caesar import *
25 from cipher.affine import *
26 from cipher.keyword_cipher import *
28 from support.text_prettify import *
29 from support.utilities import *
30 from support.plot_frequency_histogram import *
35 plaintext_a_filename = f'{challenge_number}a.plaintext'
36 plaintext_b_filename = f'{challenge_number}b.plaintext'
37 ciphertext_a_filename = f'{challenge_number}a.ciphertext'
38 ciphertext_b_filename = f'{challenge_number}b.ciphertext'
42 ca = open(ciphertext_a_filename).read()
43 cb = open(ciphertext_b_filename).read()
55 (kworda, kwrapa), score = keyword_break_mp(sca, fitness=Ptrigrams)
60 pa = keyword_decipher(ca, kworda, kwrapa)
65 open(plaintext_a_filename, 'w').write(pa)
69 (kwordb, kwrapb), score = keyword_break_mp(scb, fitness=Ptrigrams)
74 pb = keyword_decipher(cb, kwordb, kwrapb)
79 open(plaintext_b_filename, 'w').write(pb)