Exemplo n.º 1
0
 def test_dictionary_encryption(self):
     ciphertexts = itertools.tee(
         lenticrypt.DictionaryEncrypter(self.substitution_alphabet,
                                        self.plaintext_io()),
         len(self.plaintexts))
     for key, plaintext, ciphertext in zip(self.keys, self.plaintexts,
                                           ciphertexts):
         decrypted = bytes(lenticrypt.decrypt(ciphertext, BytesIO(key)))
         self.assertEqual(decrypted, plaintext)
Exemplo n.º 2
0
 def test_dictionary_encryption(self):
     ciphertext = "".join(
         lenticrypt.DictionaryEncrypter(
             self.substitution_alphabet, map(lambda s: StringIO.StringIO(s), self.plaintexts)
         )
     )
     for key, plaintext in zip(self.keys, self.plaintexts):
         decrypted = "".join(lenticrypt.decrypt(StringIO.StringIO(ciphertext), StringIO.StringIO(key)))
         self.assertEqual(decrypted, plaintext)
Exemplo n.º 3
0
 def test_dictionary_encryption(self):
     ciphertext = "".join(
         lenticrypt.DictionaryEncrypter(
             self.substitution_alphabet,
             map(lambda s: StringIO.StringIO(s), self.plaintexts)))
     for key, plaintext in zip(self.keys, self.plaintexts):
         decrypted = "".join(
             lenticrypt.decrypt(StringIO.StringIO(ciphertext),
                                StringIO.StringIO(key)))
         self.assertEqual(decrypted, plaintext)
Exemplo n.º 4
0
 def test_basic_encryption(self):
     ciphertexts = itertools.tee(lenticrypt.Encrypter(self.substitution_alphabet, self.plaintext_io()), len(self.plaintexts))
     first_length = None
     for key, plaintext, ciphertext in zip(self.keys, self.plaintexts, ciphertexts):
         decrypted = bytes(lenticrypt.decrypt(ciphertext, BytesIO(key)))
         if first_length is None:
             first_length = len(plaintext)
         else:
             if first_length > len(plaintext):
                 decrypted = decrypted[:len(plaintext)]
             elif first_length < len(plaintext):
                 plaintext = plaintext[:first_length]
         self.assertEqual(decrypted, plaintext)
Exemplo n.º 5
0
 def test_basic_encryption(self):
     ciphertext = "".join(
         lenticrypt.Encrypter(self.substitution_alphabet, map(lambda s: StringIO.StringIO(s), self.plaintexts))
     )
     first_length = None
     for key, plaintext in zip(self.keys, self.plaintexts):
         decrypted = "".join(lenticrypt.decrypt(StringIO.StringIO(ciphertext), StringIO.StringIO(key)))
         if first_length is None:
             first_length = len(plaintext)
         else:
             if first_length > len(plaintext):
                 decrypted = decrypted[: len(plaintext)]
             elif first_length < len(plaintext):
                 plaintext = plaintext[:first_length]
         self.assertEqual(decrypted, plaintext)
Exemplo n.º 6
0
 def test_basic_encryption(self):
     ciphertexts = itertools.tee(
         lenticrypt.Encrypter(self.substitution_alphabet,
                              self.plaintext_io()), len(self.plaintexts))
     first_length = None
     for key, plaintext, ciphertext in zip(self.keys, self.plaintexts,
                                           ciphertexts):
         decrypted = bytes(lenticrypt.decrypt(ciphertext, BytesIO(key)))
         if first_length is None:
             first_length = len(plaintext)
         else:
             if first_length > len(plaintext):
                 decrypted = decrypted[:len(plaintext)]
             elif first_length < len(plaintext):
                 plaintext = plaintext[:first_length]
         self.assertEqual(decrypted, plaintext)
Exemplo n.º 7
0
 def test_basic_encryption(self):
     ciphertext = "".join(
         lenticrypt.Encrypter(
             self.substitution_alphabet,
             map(lambda s: StringIO.StringIO(s), self.plaintexts)))
     first_length = None
     for key, plaintext in zip(self.keys, self.plaintexts):
         decrypted = "".join(
             lenticrypt.decrypt(StringIO.StringIO(ciphertext),
                                StringIO.StringIO(key)))
         if first_length is None:
             first_length = len(plaintext)
         else:
             if first_length > len(plaintext):
                 decrypted = decrypted[:len(plaintext)]
             elif first_length < len(plaintext):
                 plaintext = plaintext[:first_length]
         self.assertEqual(decrypted, plaintext)
Exemplo n.º 8
0
 def test_dictionary_encryption(self):
     ciphertexts = itertools.tee(lenticrypt.DictionaryEncrypter(self.substitution_alphabet, self.plaintext_io()), len(self.plaintexts))
     for key, plaintext, ciphertext in zip(self.keys, self.plaintexts, ciphertexts):
         decrypted = bytes(lenticrypt.decrypt(ciphertext, BytesIO(key)))
         self.assertEqual(decrypted, plaintext)