python2.7 关于SM2解密问题 一直报这个错有谁懂SM2么

img

Traceback (most recent call last):
File "getFileSql.py", line 55, in
sm2_crypt.decrypt(hexlify)
File "D:\python2.7\lib\site-packages\gmssl\sm2.py", line 210, in decrypt
data = data.hex()
AttributeError: 'str' object has no attribute 'hex'
PS D:\djangoProject>

不能用字符串, 要用bytes
试试 通过base64解码成二进制bytes , 再 decrypt

from base64 import b64encode, b64decode

decode_info = b64decode(hexlify.encode())
sm2_crypt.decrypt(decode_info )