duanhongyi / gmssl

a python crypto for sm2/sm3/sm4
MIT License
488 stars 141 forks source link

SM4解密set_key()函数异常报错 #65

Open Sanshimemeda opened 1 year ago

Sanshimemeda commented 1 year ago

crypt_sm4 = CryptSM4() sm4_key = bytes(value_list[1]) crypt_sm4.set_key(sm4_key, SM4_DECRYPT) 上述是报错代码,执行之后抛出以下异常

Traceback (most recent call last): File "test.py", line 22, in crypt_sm4.set_key(sm4_key, SM4_DECRYPT) File "/usr/lib/python2.7/site-packages/gmssl/sm4.py", line 95, in set_key MK[0] = get_uint32_be(key[0:4]) File "/usr/lib/python2.7/site-packages/gmssl/func.py", line 8, in get_uint32_be = lambda key_data:((key_data[0] << 24) | (key_data[1] << 16) | (key_data[2] << 8) | (key_data[3])) TypeError: unsupported operand type(s) for <<: 'str' and 'int'

Sanshimemeda commented 1 year ago

有大佬知道是什么原因吗? 我试过直接写死sm4_key = b'hdkgia12jfirajk7' 也还是报错

xuruoyu commented 1 year ago

一样的报错信息