def test_score_singlematch_multiplewords(self): self.assertEqual(18, textutils.score('abctroisdefungs', ['trois', 'un']))
from gronsfeld import gronsfeld, GronsfeldKey, textutils if __name__ == '__main__': best_score = 0 ciphertext = 'DGMOINHGNUJDRYNUNHOIUENIFNIXXLAYPTMVHSNSFYLKROIYJTDJTCCULEYEVYRTGUA'.lower( ) expected_words = [ 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'cent' ] for key in range(0, 100000000): gkey = GronsfeldKey(str(key)) cleartext = gronsfeld.decipher(ciphertext, gkey) score = textutils.score(cleartext, expected_words) if (key % 10000) == 0: print(str(key)) if score > best_score: best_score = score print(str(score) + ': ' + cleartext + '(' + str(key) + ')') print('end')
def test_score_longmatch_multiplematches(self): self.assertEqual(30, textutils.score('abctroisdeftroisgs', ['trois']))
def test_score_longmatch(self): self.assertEqual(15, textutils.score('abctroisdefg', ['trois']))
def test_score_shortmatch_multiplematches(self): self.assertEqual(2, textutils.score('abudeugn', ['un']))
def test_score_shortmatch(self): self.assertEqual(1, textutils.score('abudefgn', ['un']))
def test_score_nomatch(self): self.assertEqual(0, textutils.score('abcdefgn', ['un']))