コード例 #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())