从 block_io python 通知 json 对象验证签名

问题描述 投票:0回答:0

我在 python 中使用 block_io 来发送有关交易更新的通知,这是一个像这样的 json 格式:

{ "event_id" : "...", // 用于调试目的的事件 ID
"notification_id" : "...", // 当您发出时发出的唯一标识符 创建通知 "delivery_attempt" : 1, // 次数 我们尝试传递此事件 "type" : "...", // 的类型 通知,帮助您了解“数据”下方发送的数据:{ ... // 通知数据 }, "created_at" : 1426104819, // 我们创建此通知时的时间戳 "signature" : "..." // 此数据的签名哈希(不包括签名密钥)}

我只是想知道我如何自己从传入数据生成签名以根据传入数据验证它(显然使用我想象的我的密钥)以确保通知确实来自 block_io 而不是其他人。

尝试

json.dumps(json_obj) 到 hmac.new(secret.encode(), incoming.encode(), hashlib.sha256).hexdigest()

仍然没有得到匹配的签名

python json encoding decoding verification
© www.soinside.com 2019 - 2024. All rights reserved.