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 *
27 from support.text_prettify import *
28 from support.utilities import *
29 from support.plot_frequency_histogram import *
34 plaintext_a_filename = f'{challenge_number}a.plaintext'
35 plaintext_b_filename = f'{challenge_number}b.plaintext'
36 ciphertext_a_filename = f'{challenge_number}a.ciphertext'
37 ciphertext_b_filename = f'{challenge_number}b.ciphertext'
41 ca = open(ciphertext_a_filename).read()
42 cb = open(ciphertext_b_filename).read()
54 (ma, ca, za), score_a = affine_break(sca)
55 print((ma, ca, za), '\n')
56 pa = repunctuate(affine_decipher(sca, ma, ca, za), pta)
61 open(plaintext_a_filename, 'w').write(pa)
65 (mb, cb, zb), score_a = affine_break(scb)
66 print((mb, cb, zb), '\n')
67 pb = repunctuate(affine_decipher(scb, mb, cb, zb), ptb)
72 open(plaintext_b_filename, 'w').write(pb)