コード例 #1
0
ファイル: test_caesar.py プロジェクト: bradleyayers/pycipher
 def test_decipher(self):
     ''' Caesar (test_decipher): test known ciphertext->plaintext pairs '''
     text = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     declist = ['xyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw',
                'vwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu',
                'stuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr',
                'pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno',
                'lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk',
                'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz',
                'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza']
     for i,key in enumerate((3,5,8,11,15,0,25)):
         dec = Caesar(key).decipher(text)
         self.assertEqual(dec.upper(), declist[i].upper())
コード例 #2
0
ファイル: test_caesar.py プロジェクト: wean2016/pycipher
 def test_decipher(self):
     ''' Caesar (test_decipher): test known ciphertext->plaintext pairs '''
     text = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     declist = ['xyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw',
                'vwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu',
                'stuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr',
                'pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno',
                'lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk',
                'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz',
                'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza']
     for i,key in enumerate((3,5,8,11,15,0,25)):
         dec = Caesar(key).decipher(text)
         self.assertEqual(dec.upper(), declist[i].upper())
コード例 #3
0
ファイル: test_caesar.py プロジェクト: bradleyayers/pycipher
 def test_encipher(self):
     ''' Caesar (test_encipher): test known plaintext->ciphertext pairs '''
     text = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     enclist = ['bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza',
                'cdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab',
                'efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd',
                'hijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg',
                'jklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi',
                'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz',
                'zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy']
     for i,key in enumerate((1,2,4,7,9,0,25)):
         enc = Caesar(key).encipher(text)
         self.assertEqual(enc.upper(), enclist[i].upper())
コード例 #4
0
ファイル: test_caesar.py プロジェクト: wean2016/pycipher
 def test_encipher(self):
     ''' Caesar (test_encipher): test known plaintext->ciphertext pairs '''
     text = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     enclist = ['bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza',
                'cdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab',
                'efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd',
                'hijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg',
                'jklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi',
                'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz',
                'zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy']
     for i,key in enumerate((1,2,4,7,9,0,25)):
         enc = Caesar(key).encipher(text)
         self.assertEqual(enc.upper(), enclist[i].upper())