pydiagral 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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()