From 5eb0edaaf92cd57d685506d371858ac4fe7a55dd Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sun, 4 Sep 2022 12:48:15 +0200 Subject: [PATCH] Make hash name compatible with Python 3.9 Apparently SHA-256 with a dash works only with Python 3.10. --- app.py | 4 ++-- clients/report_loadavg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index ba75393..3108b9d 100644 --- a/app.py +++ b/app.py @@ -43,7 +43,7 @@ def verify_node(d): if "/" in node: raise ValueError("invalid node name %s", node) try: - log.info("gettingg client config from %s", "config/" + node) + log.info("getting client config from %s", "config/" + node) with open("config/" + node) as fh: node_conf = json.load(fh) except Exception as e: @@ -52,7 +52,7 @@ def verify_node(d): last = node_conf["last"] for key in node_conf["keys"]: msg = (node + " " + str(timestamp)).encode("UTF-8") - hmac2 = hmac.new(key.encode("UTF-8"), msg, "SHA-256") + hmac2 = hmac.new(key.encode("UTF-8"), msg, "SHA256") digest2 = hmac2.hexdigest() if hmac.compare_digest(digest1, digest2): if timestamp > node_conf["last"]: diff --git a/clients/report_loadavg b/clients/report_loadavg index c70c4d2..b5036c9 100755 --- a/clients/report_loadavg +++ b/clients/report_loadavg @@ -25,7 +25,7 @@ def report_loadavg(): node = hostname timestamp = time.time() msg = (node + " " + str(timestamp)).encode("UTF-8") - digest = hmac.new(client_config["key"].encode("UTF-8"), msg, "SHA-256").hexdigest() + digest = hmac.new(client_config["key"].encode("UTF-8"), msg, "SHA256").hexdigest() report.append( { "description": {