def test_encrypt_and_decrypt(self): key = AESHandler.figure_32Byte_key('provide a key') text = 'test encrypt and decrypt.' ciphertext = AESHandler.encrypt(text, key) plaintext = AESHandler.decrypt(ciphertext, key) self.assertEqual(text, plaintext)
def test_32byte_key_generate(self): key1 = AESHandler.figure_32Byte_key('not enough 32 bytes') key2 = AESHandler.figure_32Byte_key('exceed 32 bytes' * 3) self.assertTrue(key1.startswith('not enough 32 bytes')) self.assertEqual(len(key1), 32) self.assertEqual(len(key2), 32)