forked from BD-Python-PIP/code-examples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect_test.py
More file actions
14 lines (12 loc) · 622 Bytes
/
connect_test.py
File metadata and controls
14 lines (12 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def validateHMAC():
import hmac
import hashlib
import base64
file = open("payload.txt", "rb") # Read the payload from a file named payload.txt
payload = file.read()
secret = "4+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxuE=" # Replace this value with your own secret
signature = "e4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhg=" # Replace this value with your own signature
hashBytes = hmac.new(str.encode(secret), msg=payload, digestmod=hashlib.sha256).digest()
base64Hash = base64.b64encode(hashBytes)
return hmac.compare_digest(str.encode(signature), base64Hash)
print(validateHMAC())