test_crypto.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:mflod 作者: arachnid42 项目源码 文件源码
def test_aes_encryption_consistency(self):

        # test encryption-decryption for each test message
        for msg in self.TEST_MSGS:

            # precreate simple ASN.1 structure to encode and encrypt
            test_der = encode(OctetString(msg))

            # generate random IV and a key
            iv = urandom(16)
            key = urandom(16)

            # encrypt and decrypt message
            ct = self.crypto_obj._Crypto__encrypt_with_aes(test_der, key, iv)
            pt = self.crypto_obj._Crypto__decrypt_with_aes(ct, key, iv)

            # check whether they are equal
            self.assertEqual(test_der, pt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号