def test_encrypt_and_decrypt(self): key_hex = utils.gen_aes_key_hex() content = json.dumps({'command': 'test'}) cipher_string = utils.json_encrypt(key_hex, content) after = utils.json_decrypt(key_hex, cipher_string) self.assertEqual(after, content, 'test encrypt and decrypt fail')
def test_gen_aes_key(self): self.assertEqual(len(utils.gen_aes_key_hex()), 32, 'test gen command bytes array fail, the length is %d' % len(utils.gen_aes_key_hex()))
def test_gen_aes_key(self): self.assertEqual( len(utils.gen_aes_key_hex()), 32, 'test gen command bytes array fail, the length is %d' % len(utils.gen_aes_key_hex()))