Пример #1
0
 def test_decrypt_two_char_key(self):
     self.assertEqual("in the fire", decrypt(encrypt('in the fire', 'AB'), 2).lower())
     self.assertEqual("in the mood", decrypt(encrypt('in the mood', 'BA'), 2).lower())
     self.assertEqual("in the midst", decrypt(encrypt('in the midst', 'CD'), 2).lower())
Пример #2
0
 def test_project_euler(self):
     infile = open(os.path.join(os.path.dirname(__file__), 'cipher1.txt'))
     encrypted = map(int, infile.read().split(","))
     infile.close()
     res = sum(map(ord, decrypt(encrypted, 3)))
     self.assertEqual(107359, res)
Пример #3
0
 def test_decrypt_single_char_key(self):
     self.assertEqual("in the fire", decrypt(encrypt('in the fire', 'A'), 1).lower())
     self.assertEqual("in the moment", decrypt(encrypt('in the moment', 'A'), 1).lower())
     self.assertEqual("in the mood", decrypt(encrypt('in the mood', 'B'), 1).lower())
     self.assertEqual("in the midst", decrypt(encrypt('in the midst', 'C'), 1).lower())