Exemplo n.º 1
0
 def test_encipher(self):
     keys = ('abronjdfuetchiszlgwqvxkymp', 'mufykewgqtnrlopcbadsvxzijh',
             'rtuzesbxjaniypqclghmvwodkf', 'ymdsvtxizewurqfnbgjlckoahp',
             'lcvmwezojbgdtsrniufyqphxak')
     plaintext = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     ciphertext = ('abronjdfuetchiszlgwqvxkympabronjdfuetchiszlgwqvxkymp',
                   'mufykewgqtnrlopcbadsvxzijhmufykewgqtnrlopcbadsvxzijh',
                   'rtuzesbxjaniypqclghmvwodkfrtuzesbxjaniypqclghmvwodkf',
                   'ymdsvtxizewurqfnbgjlckoahpymdsvtxizewurqfnbgjlckoahp',
                   'lcvmwezojbgdtsrniufyqphxaklcvmwezojbgdtsrniufyqphxak')
     for i, key in enumerate(keys):
         enc = SimpleSubstitution(key).encipher(plaintext)
         self.assertEqual(enc.upper(), ciphertext[i].upper())
Exemplo n.º 2
0
 def test_decipher(self):
     keys = ('zidvgmlefwpsktrnaoqjyubhxc', 'wyqtnaopsxigdbzlhumvckrejf',
             'bqcjpkfeuzlnxmgdastwhriyvo', 'enwdirhmykbfzsaojulpcqtvxg',
             'rtzeawivnubkyjfchsldomqxpg')
     ciphertext = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     plaintext = ('qwzchiexbtmgfprksolnvdjyuaqwzchiexbtmgfprksolnvdjyua',
                  'fnumxzlqkyvpseghcwidrtajbofnumxzlqkyvpseghcwidrtajbo',
                  'qacphgouwdfknlzebvrsiytmxjqacphgouwdfknlzebvrsiytmxj',
                  'okudalzgeqjshbptvfnwrxcyimokudalzgeqjshbptvfnwrxcyim',
                  'ekptdozqgnlsviuywarbjhfxmcekptdozqgnlsviuywarbjhfxmc')
     for i, key in enumerate(keys):
         dec = SimpleSubstitution(key).decipher(ciphertext)
         self.assertEqual(dec.upper(), plaintext[i].upper())
Exemplo n.º 3
0
 def test_encipher(self):
     keys = ('abronjdfuetchiszlgwqvxkymp',
             'mufykewgqtnrlopcbadsvxzijh',
             'rtuzesbxjaniypqclghmvwodkf',
             'ymdsvtxizewurqfnbgjlckoahp',
             'lcvmwezojbgdtsrniufyqphxak')
     plaintext = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     ciphertext = ('abronjdfuetchiszlgwqvxkympabronjdfuetchiszlgwqvxkymp',
                   'mufykewgqtnrlopcbadsvxzijhmufykewgqtnrlopcbadsvxzijh',
                   'rtuzesbxjaniypqclghmvwodkfrtuzesbxjaniypqclghmvwodkf',
                   'ymdsvtxizewurqfnbgjlckoahpymdsvtxizewurqfnbgjlckoahp',
                   'lcvmwezojbgdtsrniufyqphxaklcvmwezojbgdtsrniufyqphxak')
     for i,key in enumerate(keys):
         enc = SimpleSubstitution(key).encipher(plaintext)
         self.assertEqual(enc.upper(), ciphertext[i].upper())
Exemplo n.º 4
0
 def test_decipher(self):
     keys = ('zidvgmlefwpsktrnaoqjyubhxc',
             'wyqtnaopsxigdbzlhumvckrejf',
             'bqcjpkfeuzlnxmgdastwhriyvo',
             'enwdirhmykbfzsaojulpcqtvxg',
             'rtzeawivnubkyjfchsldomqxpg')
     ciphertext = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     plaintext = ('qwzchiexbtmgfprksolnvdjyuaqwzchiexbtmgfprksolnvdjyua',
                  'fnumxzlqkyvpseghcwidrtajbofnumxzlqkyvpseghcwidrtajbo',
                  'qacphgouwdfknlzebvrsiytmxjqacphgouwdfknlzebvrsiytmxj',
                  'okudalzgeqjshbptvfnwrxcyimokudalzgeqjshbptvfnwrxcyim',
                  'ekptdozqgnlsviuywarbjhfxmcekptdozqgnlsviuywarbjhfxmc')
     for i,key in enumerate(keys):
         dec = SimpleSubstitution(key).decipher(ciphertext)
         self.assertEqual(dec.upper(), plaintext[i].upper())