pydiagral 1.0.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pydiagral/utils.py ADDED
@@ -0,0 +1,14 @@
1
+ """Module providing utility functions for Diagral API."""
2
+
3
+ import hashlib
4
+ import hmac
5
+ import time
6
+
7
+
8
+ def generate_hmac_signature(
9
+ timestamp: str, serial_id: str, api_key: str, secret_key: str
10
+ ) -> str:
11
+ """Generate an HMAC signature for the given parameters."""
12
+ timestamp = str(int(time.time()))
13
+ message = f"{timestamp}.{serial_id}.{api_key}"
14
+ return hmac.new(secret_key.encode(), message.encode(), hashlib.sha256).hexdigest()