Open Sanshimemeda opened 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'
有大佬知道是什么原因吗? 我试过直接写死sm4_key = b'hdkgia12jfirajk7' 也还是报错
一样的报错信息
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'