Exemplo n.º 1
0
 def test_aes_encrypt(self):
     """Testing aes_encrypt"""
     # The encrypted value will change every time, since the iv changes,
     # so we can't compare a direct value. Instead, we need to ensure that
     # we can decrypt what we encrypt.
     self.assertEqual(aes_decrypt(aes_encrypt(self.PLAIN_TEXT)),
                      self.PLAIN_TEXT)
Exemplo n.º 2
0
 def test_aes_encrypt(self):
     """Testing aes_encrypt"""
     # The encrypted value will change every time, since the iv changes,
     # so we can't compare a direct value. Instead, we need to ensure that
     # we can decrypt what we encrypt.
     self.assertEqual(aes_decrypt(aes_encrypt(self.PLAIN_TEXT)),
                      self.PLAIN_TEXT)
Exemplo n.º 3
0
 def test_aes_encrypt_with_unicode(self):
     """Testing aes_encrypt with Unicode string"""
     # The encrypted value will change every time, since the iv changes,
     # so we can't compare a direct value. Instead, we need to ensure that
     # we can decrypt what we encrypt.
     encrypted = aes_encrypt(self.PLAIN_TEXT_UNICODE)
     self.assertIsInstance(encrypted, bytes)
     self.assertEqual(aes_decrypt(encrypted), self.PLAIN_TEXT_BYTES)
Exemplo n.º 4
0
    def test_aes_encrypt_with_custom_key(self):
        """Testing aes_encrypt with custom key"""
        # The encrypted value will change every time, since the iv changes,
        # so we can't compare a direct value. Instead, we need to ensure that
        # we can decrypt what we encrypt.
        encrypted = aes_encrypt(self.PLAIN_TEXT, key=self.CUSTOM_KEY)

        self.assertEqual(aes_decrypt(encrypted, key=self.CUSTOM_KEY),
                         self.PLAIN_TEXT)
Exemplo n.º 5
0
    def test_aes_encrypt_with_custom_key(self):
        """Testing aes_encrypt with custom key"""
        # The encrypted value will change every time, since the iv changes,
        # so we can't compare a direct value. Instead, we need to ensure that
        # we can decrypt what we encrypt.
        encrypted = aes_encrypt(self.PLAIN_TEXT, key=self.CUSTOM_KEY)

        self.assertEqual(aes_decrypt(encrypted, key=self.CUSTOM_KEY),
                         self.PLAIN_TEXT)