9 jupytext_version: 1.11.1
11 display_name: Python 3 (ipykernel)
16 ```python Collapsed="false"
17 from szyfrow.caesar import *
18 from szyfrow.affine import *
19 from szyfrow.keyword_cipher import *
20 from szyfrow.column_transposition import *
21 from szyfrow.vigenere import *
22 from szyfrow.polybius import *
23 from szyfrow.railfence import *
24 from szyfrow.hill import *
25 from szyfrow.support.text_prettify import *
29 import matplotlib.pyplot as plt
35 ```python Collapsed="false"
37 plaintext_a_filename = f'plaintext.{challenge_number}a.txt'
38 plaintext_b_filename = f'plaintext.{challenge_number}b.txt'
39 ciphertext_a_filename = f'ciphertext.{challenge_number}a.txt'
40 ciphertext_b_filename = f'ciphertext.{challenge_number}b.txt'
43 ```python Collapsed="false"
44 ca = open(ciphertext_a_filename).read()
45 cb = open(ciphertext_b_filename).read()
49 rsca = cat(reversed(sca))
51 rscb = cat(reversed(scb))
55 sca_counts = collections.Counter(sca)
60 pd.Series(sca_counts).sort_index().plot.bar()
68 permutes = [transpositions_of(cat(t)) for t in itertools.permutations('abcdefghi')]
73 key_a, _ = column_transposition_break(sca, translist=permutes, fitness=Ptrigrams)
74 word_a, fill_a, empty_a = key_a
75 word_a, fill_a, empty_a
79 # mod_word_a = (1, 3, 6, 4, 5, 7, 0, 2, 8)
80 pa = column_transposition_decipher(sca, word_a,
81 fillcolumnwise=fill_a, emptycolumnwise=empty_a)
89 ```python Collapsed="false" tags=[]
90 open(plaintext_a_filename, 'w').write(prettify(pa))
94 scb_counts = collections.Counter(scb)
99 pd.Series(scb_counts).sort_index().plot.bar()
103 key_b, _ = hill_break(scb, fitness=Ptrigrams)
111 pb = hill_decipher(key_b, scb)
119 ```python Collapsed="false"
120 open(plaintext_b_filename, 'w').write(prettify(pb))
123 ```python Collapsed="false"