2022-12-16 21:36:35 +08:00
|
|
|
import hmac
|
|
|
|
|
|
|
|
secret = "0123456789"
|
|
|
|
payload = "helloworld"
|
|
|
|
|
2022-12-18 15:40:37 +08:00
|
|
|
h = hmac.new(secret.encode(),digestmod="md5")
|
2022-12-16 21:36:35 +08:00
|
|
|
h.update(payload.encode())
|
|
|
|
print("hmac-md5:",h.hexdigest())
|
|
|
|
|
2022-12-18 15:40:37 +08:00
|
|
|
h = hmac.new(secret.encode(),digestmod="sha1")
|
2022-12-16 21:36:35 +08:00
|
|
|
h.update(payload.encode())
|
|
|
|
print("hmac-sha1:",h.hexdigest())
|
|
|
|
|
2022-12-18 15:40:37 +08:00
|
|
|
h = hmac.new(secret.encode(),digestmod="sha256")
|
2022-12-16 21:36:35 +08:00
|
|
|
h.update(payload.encode())
|
|
|
|
print("hmac-sha256:",h.hexdigest())
|