Skip to content

Instantly share code, notes, and snippets.

@ardzz
Last active February 11, 2025 13:55
Show Gist options
  • Save ardzz/5287638cca46920b0e413e2264bc4f42 to your computer and use it in GitHub Desktop.
Save ardzz/5287638cca46920b0e413e2264bc4f42 to your computer and use it in GitHub Desktop.
import hashlib
import json
def generate_hmac(key, message):
return hashlib.sha256(key.encode() + message.encode()).hexdigest()
data = {"name": "Reky", "email": "[email protected]"}
data_json = json.dumps(data)
print("Data JSON:", data_json)
print("HMAC:", generate_hmac("very_secret", data_json))
PUT /profile HTTP/1.1
Host: api.reky.id
Content-Type: application/json
Date: Tue, 11 Feb 2025 12:00:00 GMT
Hmac: 63b840b5a5d3a4ea3c203571fa4489952aad23050056fc01391e24ef804b4c25
{"name": "Reky","email": "[email protected]"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment