We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 99fd732 commit 6e54936Copy full SHA for 6e54936
pydatastructs/graphs/graph.py
@@ -21,6 +21,12 @@ def get_secret_key():
21
def generate_hmac(data):
22
"""Generating HMAC signature for integrity verification"""
23
return hmac.new(get_secret_key(), data.encode(),hashlib.sha256).haxdigit()
24
+def serialize_graph(graph):
25
+ """Converts a graph into a string for HMAC signing."""
26
+ if not graph.vertices or not graph.edge_weights:
27
+ return "EMPTY_GRAPH"
28
+ return str(sorted(graph.vertices)) + str(sorted(graph.edge_weights.items()))
29
+
30
__all__ = [
31
'Graph'
32
]
0 commit comments