Example #1
0
 def test_autokey(self):
     hpf.main(algorithm=1,
              shift_id=0,
              reversed_text=False,
              reverse_gematria=False,
              interrupter=None,
              ciphertext=tt.test_autokey_encryption_ct())
     df = pd.read_csv('keys.txt', sep=',')
     self.assertEqual(
         hpf.translate_to_english(tt.test_autokey_encryption_plaintext(),
                                  reverse_gematria=False),
         df.loc[0, 'Message text'])
Example #2
0
 def test_vigenere_decryption_koan2(self):
     interrupter = 0
     plaintext = tt.get_koan2_plaintext()
     ct = tt.get_koan2_text()
     hpf.main(algorithm=0,
              shift_id=0,
              reversed_text=False,
              reverse_gematria=False,
              interrupter=interrupter,
              ciphertext=ct)
     df = pd.read_csv('keys.txt', sep=',')
     self.assertEqual(
         hpf.translate_to_english(tt.get_koan2_plaintext(),
                                  reverse_gematria=False),
         df.loc[0, 'Message text'])
Example #3
0
    def test_autokey_full(self):
        key = np.array([20, 10, 17, 18, 4])  # Liber
        interrupter = 0
        ct = enc.autokey_encryption(tt.get_koan2_plaintext(), interrupter, key)

        hpf.main(algorithm=1,
                 shift_id=0,
                 reversed_text=False,
                 reverse_gematria=False,
                 interrupter=0,
                 ciphertext=ct)
        df = pd.read_csv('keys.txt', sep=',')
        self.assertEqual(
            hpf.translate_to_english(tt.get_koan2_plaintext(),
                                     reverse_gematria=False),
            df.loc[0, 'Message text'])
Example #4
0
 def test_autokey_shift0(self):
     interrupter = 0
     ct_numbers = tt.get_koan2_plaintext()
     interrupter_array = np.asarray(ct_numbers == interrupter)
     ciphertext = enc.encrypt_text(plaintext=ct_numbers,
                                   algorithm='Autokey',
                                   shift_id=0,
                                   reverse_text=False,
                                   reverse_gematria=False,
                                   interrupter=interrupter,
                                   key=np.array(
                                       [0, 10, 15, 8, 18, 4, 19, 24, 9]),
                                   interrupter_array=interrupter_array)
     hpf.main(algorithm=1,
              shift_id=0,
              reversed_text=False,
              reverse_gematria=False,
              interrupter=interrupter,
              ciphertext=ciphertext)
     df = pd.read_csv('keys.txt', sep=',')
     self.assertEqual(
         hpf.translate_to_english(tt.get_koan2_plaintext(),
                                  reverse_gematria=False),
         df.loc[0, 'Message text'])