Ejemplo n.º 1
0
 def test_score_singlematch_multiplewords(self):
     self.assertEqual(18, textutils.score('abctroisdefungs', ['trois', 'un']))
Ejemplo n.º 2
0
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')
Ejemplo n.º 3
0
 def test_score_longmatch_multiplematches(self):
     self.assertEqual(30, textutils.score('abctroisdeftroisgs', ['trois']))
Ejemplo n.º 4
0
 def test_score_longmatch(self):
     self.assertEqual(15, textutils.score('abctroisdefg', ['trois']))
Ejemplo n.º 5
0
 def test_score_shortmatch_multiplematches(self):
     self.assertEqual(2, textutils.score('abudeugn', ['un']))
Ejemplo n.º 6
0
 def test_score_shortmatch(self):
     self.assertEqual(1, textutils.score('abudefgn', ['un']))
Ejemplo n.º 7
0
 def test_score_nomatch(self):
     self.assertEqual(0, textutils.score('abcdefgn', ['un']))