【发布时间】:2016-11-03 04:08:19
【问题描述】:
我尝试根据instructions在python中使用HMAC-SHA256编码消息
import hmac
import hashlib
nonce = 1234
customer_id = 123232
api_key = 2342342348273482374343434
API_SECRET = 892374928347928347283473
message = nonce + customer_id + api_key
signature = hmac.new(
API_SECRET,
msg=message,
digestmod=hashlib.sha256
).hexdigest().upper()
但我明白了
Traceback(最近一次调用最后一次):文件“gen.py”,第 13 行,在 digestmod=hashlib.sha256 文件“/usr/lib/python2.7/hmac.py”,第 136 行,新 return HMAC(key, msg, digestmod) File "/usr/lib/python2.7/hmac.py", line 71, in init if len(key) > blocksize: TypeError: 'long' 类型的对象没有 len()
有人知道为什么会崩溃吗?
【问题讨论】: