def aes128_decrypt(self, msg):
iv = os.urandom(16)
aes_obj = AES.new(self.key, AES.MODE_CBC, iv)
decrypted_msg = aes_obj.decrypt(msg)
return decrypted_msg
我正在使用它来解密,并且 msg 作为字节数组传入。我正在使用 Python 3 和 pycryptodome 库进行 AES128 加密。我看到的错误是:
msg = bytearray(b'M\xb1\xbfw\xf4o\x15\xff\xda{u\xba)\xcd\x9fu\x80\xb2\x0c*s\x17%6\xfeA\xb84\xab\x89\xff\x16A\xb8')
def expect_byte_string(data):
if not byte_string(data) and not isinstance(data, Array):
raise TypeError("Only byte strings can be passed to C code")
TypeError: Only byte strings can be passed to C code