简体   繁体   English

你如何转换“最终字符串 webhookSignature = new HmacUtils(HmacAlgorithms.HMAC_SHA_1, webhookSecret).hmacHex(webhookBody);” 从 java 到 python

[英]How do you convert "final String webhookSignature = new HmacUtils(HmacAlgorithms.HMAC_SHA_1, webhookSecret).hmacHex(webhookBody);" from java to python

I'm just not experienced enough in java to figure this out, but if anyone knows the equivalent of this code in python, that would be greatly appreciated:我只是在 java 中没有足够的经验来解决这个问题,但是如果有人知道 python 中的等效代码,那将不胜感激:

final String webhookSignature = new HmacUtils(HmacAlgorithms.HMAC_SHA_1, webhookSecret).hmacHex(webhookBody);

Here is the original source: https://apidocs.rhombussystems.com/reference/simple-webhooks这是原始来源: https://apidocs.rhombussystems.com/reference/simple-webhooks

It should be approximately this:应该是这样的:

import hmac
import hashlib

key = bytes(webhookSecret, 'UTF-8')
message = bytes(webhookBody, 'UTF-8')  
digester = hmac.new(key, message, hashlib.sha1)
signature1 = digester.hexdigest()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM