Make hash name compatible with Python 3.9

Apparently SHA-256 with a dash works only with Python 3.10.
This commit is contained in:
Peter J. Holzer 2022-09-04 12:48:15 +02:00
parent 67bb915e49
commit 5eb0edaaf9
2 changed files with 3 additions and 3 deletions

4
app.py
View File

@ -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"]:

View File

@ -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": {