예제 #1
0
 def test_encode_decode(self):
     for i in range(0, 100):
         plaintext = ""
         for j in range(0, random.randint(20, 50)):
             plaintext += chr(random.randint(65, 90))
         key = chr(random.randint(65, 90))
         self.assertEqual(shift_cipher.decode(shift_cipher.encode(plaintext, key), key), plaintext)
예제 #2
0
 def test_string_encode(self):
     self.assertEqual(shift_cipher.encode("HELLO WORLD", "C"), "JGNNQ YQTNF")
예제 #3
0
 def test_single_character_encode(self):
     self.assertEqual(shift_cipher.encode("C", "N"), "P")
예제 #4
0
 def test_brute_force(self):
     brute_force_result = shift_cipher.brute_force_search("HELLO WORLD")
     for i in range(0, 26):
         self.assertEqual(shift_cipher.encode(brute_force_result[i], chr(i + 65)), "HELLO WORLD")