也许你应该用暴力来强迫API文档?在>>> secret1 = 'qwer-qewr-qwer-qwer'
>>> secret2 = 'qwer-qwer-qwer-qwer'
>>> message_template = 'key=asdf-asdf-asdf-asdf&nonce={}&coin=btc&id=3'
>>> target = '66b2935f3ba82a4a17074d439adab1043a63df4a177af68fe76a3f4f350ef55d'
>>> keys = [hashlib.md5(secret1).hexdigest(), hashlib.md5(secret1).digest(), hashlib.md5(secret2).hexdigest(), hashlib.md5(secret2).digest()]
>>>
>>> for i in range(1505000000, 1506000000):
... msg = message_template.format(i)
... for key in keys:
... if hmac.new(key, msg, hashlib.sha256).hexdigest() == target:
... print 'FOUND hmac', key, msg
... if hashlib.sha256(key + msg).hexdigest() == target:
... print 'FOUND sha256', key, msg
...
FOUND hmac fecfe400baa3ae47fe8c42f9c087ec90 key=asdf-asdf-asdf-asdf&nonce=1505209413&coin=btc&id=3
对应于:
^{pr2}$
因此,以下方法应该有效:>>> hmac.new(hashlib.md5('qwer-qewr-qwer-qwer').hexdigest(), 'key=asdf-asdf-asdf-asdf&nonce=1505209413&coin=btc&id=3', hashlib.sha256).hexdigest()
'66b2935f3ba82a4a17074d439adab1043a63df4a177af68fe76a3f4f350ef55d'
看起来您做的事情是正确的,但是它们的nonce发生了变化,qwer-qewr-qwer-qwer私钥是正确的。在