예제 #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())
예제 #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())
예제 #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())
예제 #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())