def test_encode_wraps_z_to_a(self):
     cipher = Cipher()
     plaintext = 'z'
     ciphertext = 'a'
     self.assertEqual(ciphertext, cipher.encode(plaintext))
Пример #2
0
 def test_can_double_shift_encode(self):
     plaintext = 'iamapandabear'
     cipher = Cipher(plaintext)
     self.assertEqual(cipher.encode(plaintext), 'qayaeaagaciai')
Пример #3
0
 def test_can_encode_messages_longer_than_key(self):
     cipher = Cipher('abc')
     self.assertEqual(cipher.encode('iamapandabear'), 'iboaqcnecbfcr')
Пример #4
0
 def test_cipher_compositiion1(self):
     key = ('duxrceqyaimciuucnelkeoxjhdyduucpmrxmaivacmybmsdrzwqxvbxsy'
            'gzsabdjmdjabeorttiwinfrpmpogvabiofqexnohrqu')
     plaintext = 'adaywithoutlaughterisadaywasted'
     c = Cipher(key)
     self.assertEqual(c.decode(c.encode(plaintext)), plaintext)
Пример #5
0
 def test_can_encode(self):
     cipher = Cipher('abcdefghij')
     self.assertEqual(cipher.encode('aaaaaaaaaa'), cipher.key)
 def test_encode_always_returns_downcase_string(self):
     cipher = Cipher()
     plaintext = 'AbCdEfGhIj'
     ciphertext = 'bcdefghijk'
     self.assertEqual(ciphertext, cipher.encode(plaintext))
Пример #7
0
 def test_cipher_encode4(self):
     key = ('duxrceqyaimciuucnelkeoxjhdyduucpmrxmaivacmybmsdrzwqxvbxsy'
            'gzsabdjmdjabeorttiwinfrpmpogvabiofqexnohrqu')
     c = Cipher(key)
     self.assertEqual(c.encode('diffiehellman'), 'gccwkixcltycv')
Пример #8
0
 def test_can_encode(self):
     cipher = Cipher("abcdefghij")
     plaintext = "aaaaaaaaaa"
     self.assertEqual(cipher.encode(plaintext), cipher.key)
Пример #9
0
 def test_can_double_shift_encode(self):
     cipher = Cipher("iamapandabear")
     plaintext = "iamapandabear"
     self.assertEqual(cipher.encode(plaintext), "qayaeaagaciai")
Пример #10
0
 def test_can_wrap_on_encode(self):
     cipher = Cipher('abcdefghij')
     self.assertEqual(cipher.encode('zzzzzzzzzz'), 'zabcdefghi')
Пример #11
0
 def test_can_handle_messages_longer_than_key(self):
     cipher = Cipher('abc')
     self.assertEqual(cipher.encode('iamapandabear'), 'iboaqcnecbfcr')
Пример #12
0
 def test_can_double_shift_encode(self):
     plaintext = 'iamapandabear'
     cipher = Cipher(plaintext)
     self.assertEqual(cipher.encode(plaintext), 'qayaeaagaciai')
Пример #13
0
 def test_is_reversible(self):
     cipher = Cipher('abcdefghij')
     plaintext = 'abcdefghij'
     self.assertEqual(cipher.decode(cipher.encode(plaintext)), plaintext)
Пример #14
0
 def test_can_encode(self):
     cipher = Cipher('abcdefghij')
     self.assertEqual(cipher.encode('aaaaaaaaaa'), cipher.key)
 def test_encode_with_10_shift_distance(self):
     cipher = Cipher()
     plaintext = 'wxyzabcd'
     ciphertext = 'ghijklmn'
     self.assertEqual(ciphertext, cipher.encode(plaintext, 10))
Пример #16
0
 def test_can_wrap_on_encode(self):
     cipher = Cipher("abcdefghij")
     plaintext = "zzzzzzzzzz"
     self.assertEqual(cipher.encode(plaintext), "zabcdefghi")
 def test_encode_with_27_shift_distance(self):
     cipher = Cipher()
     plaintext = 'wxyzabcd'
     ciphertext = 'xyzabcde'
     self.assertEqual(ciphertext, cipher.encode(plaintext, 27))
Пример #18
0
 def test_can_encode_messages_longer_than_the_key(self):
     cipher = Cipher("abc")
     plaintext = "iamapandabear"
     self.assertEqual(cipher.encode(plaintext), "iboaqcnecbfcr")
Пример #19
0
 def test_can_encode(self):
     cipher = Cipher()
     plaintext = 'aaaaaaaaaa'
     self.assertEqual(cipher.encode(plaintext), cipher.key[:len(plaintext)])
Пример #20
0
 def test_cipher_encode2(self):
     c = Cipher('aaaaaaaaaaaaaaaaaaaaaa')
     self.assertEqual('itisawesomeprogramminginpython',
                      c.encode('itisawesomeprogramminginpython'))
Пример #21
0
 def test_cipher_encode_short_key(self):
     c = Cipher('abcd')
     self.assertEqual(c.encode('aaaaaaaa'), 'abcdabcd')
Пример #22
0
 def test_cipher_encode3(self):
     c = Cipher('dddddddddddddddddddddd')
     self.assertEqual('yhqlylglylfl', c.encode('venividivici'))
Пример #23
0
 def test_cipher_compositiion2(self):
     plaintext = 'adaywithoutlaughterisadaywasted'
     c = Cipher()
     self.assertEqual(c.decode(c.encode(plaintext)), plaintext)
Пример #24
0
 def test_cipher_encode4(self):
     key = ('duxrceqyaimciuucnelkeoxjhdyduucpmrxmaivacmybmsdrzwqxvbxsy'
            'gzsabdjmdjabeorttiwinfrpmpogvabiofqexnohrqu')
     c = Cipher(key)
     self.assertEqual('gccwkixcltycv', c.encode('diffiehellman'))
Пример #25
0
 def test_is_reversible(self):
     cipher = Cipher('abcdefghij')
     plaintext = 'abcdefghij'
     self.assertEqual(cipher.decode(cipher.encode(plaintext)), plaintext)
Пример #26
0
 def test_cipher_encode_short_key(self):
     c = Cipher('abcd')
     self.assertEqual('abcdabcd', c.encode('aaaaaaaa'))
Пример #27
0
 def test_can_wrap_on_encode(self):
     cipher = Cipher('abcdefghij')
     self.assertEqual(cipher.encode('zzzzzzzzzz'), 'zabcdefghi')
Пример #28
0
 def test_cipher_compositiion1(self):
     key = ('duxrceqyaimciuucnelkeoxjhdyduucpmrxmaivacmybmsdrzwqxvbxsy'
            'gzsabdjmdjabeorttiwinfrpmpogvabiofqexnohrqu')
     plaintext = 'adaywithoutlaughterisadaywasted'
     c = Cipher(key)
     self.assertEqual(plaintext, c.decode(c.encode(plaintext)))
 def test_encode_raise_error_if_non_letter_characters(self):
     cipher = Cipher()
     plaintext = 'az4'
     with pytest.raises(Exception):
         cipher.encode(plaintext)
Пример #30
0
 def test_cipher_compositiion2(self):
     plaintext = 'adaywithoutlaughterisadaywasted'
     c = Cipher()
     self.assertEqual(plaintext, c.decode(c.encode(plaintext)))
 def test_encode_string_with_default_shift_distance(self):
     cipher = Cipher()
     plaintext = 'wxyzabcd'
     ciphertext = 'xyzabcde'
     self.assertEqual(ciphertext, cipher.encode(plaintext))
Пример #32
0
 def test_cipher_combo_short_key(self):
     text = 'awbxcydz'
     c = Cipher('abcd')
     cipher = c.encode(text)
     self.assertEqual(cipher, 'axdaczfc')
     self.assertEqual(c.decode(cipher), text)
 def test_encode_with_26_shift_distance(self):
     cipher = Cipher()
     plaintext = 'abcdefghij'
     ciphertext = 'abcdefghij'
     self.assertEqual(ciphertext, cipher.encode(plaintext, 26))
Пример #34
0
 def test_cipher_encode2(self):
     c = Cipher('aaaaaaaaaaaaaaaaaaaaaa')
     self.assertEqual(c.encode('itisawesomeprogramminginpython'),
                      'itisawesomeprogramminginpython')
 def test_encode_letter_with_default_shift_distance(self):
     cipher = Cipher()
     plaintext = 'a'
     ciphertext = 'b'
     self.assertEqual(ciphertext, cipher.encode(plaintext))
Пример #36
0
 def test_cipher_encode3(self):
     c = Cipher('dddddddddddddddddddddd')
     self.assertEqual(c.encode('venividivici'), 'yhqlylglylfl')
Пример #37
0
 def test_can_encode(self):
     cipher = Cipher()
     plaintext = 'aaaaaaaaaa'
     self.assertEqual(cipher.encode(plaintext), cipher.key[:len(plaintext)])
Пример #38
0
 def test_can_encode(self):
     cipher = Cipher()
     self.assertEqual(cipher.encode('aaaaaaaaaa'), cipher.key[:10])