From 2adff354483ab7c2e615d6ad646d0b75c9c7803d Mon Sep 17 00:00:00 2001 From: anning <864399407@qq.com> Date: Fri, 25 Mar 2022 18:12:40 +0800 Subject: [PATCH] Solve the problem of Object type cannot be passed to C code --- alipay/aop/api/util/EncryptUtils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/alipay/aop/api/util/EncryptUtils.py b/alipay/aop/api/util/EncryptUtils.py index 9036dc66f..36a7ac100 100644 --- a/alipay/aop/api/util/EncryptUtils.py +++ b/alipay/aop/api/util/EncryptUtils.py @@ -30,6 +30,8 @@ def aes_encrypt_content(content, encrypt_key, charset): length = len(bytes(content)) padded_content = pad(content, length) iv = '\0' * BLOCK_SIZE + if PYTHON_VERSION_3: + iv = bytes(iv, encoding="utf8") cryptor = AES.new(base64.b64decode(encrypt_key), AES.MODE_CBC, iv) encrypted_content = cryptor.encrypt(padded_content) encrypted_content = base64.b64encode(encrypted_content) @@ -47,6 +49,8 @@ def decrypt_content(encrypted_content, encrypt_type, encrypt_key, charset): def aes_decrypt_content(encrypted_content, encrypt_key, charset): encrypted_content = base64.b64decode(encrypted_content) iv = '\0' * BLOCK_SIZE + if PYTHON_VERSION_3: + iv = bytes(iv, encoding="utf8") cryptor = AES.new(base64.b64decode(encrypt_key), AES.MODE_CBC, iv) content = unpad(cryptor.decrypt(encrypted_content)) if PYTHON_VERSION_3: