From: Michael Tremer Date: Fri, 7 May 2021 11:07:05 +0000 (+0000) Subject: system: Pass any data into hashlib as bytes X-Git-Tag: v2.2.0~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c016bb5310ea4a99e4b866a449dbbc00cb829050;p=oddments%2Ffireinfo.git system: Pass any data into hashlib as bytes Signed-off-by: Michael Tremer --- diff --git a/src/fireinfo/system.py b/src/fireinfo/system.py index 9923ff6..63b67fc 100644 --- a/src/fireinfo/system.py +++ b/src/fireinfo/system.py @@ -189,7 +189,8 @@ class System(object, metaclass=Singleton): if not public_id: return "0" * 40 - return hashlib.sha1(public_id).hexdigest() + h = hashlib.sha1(public_id.encode()) + return h.hexdigest() @property def private_id(self): @@ -206,7 +207,8 @@ class System(object, metaclass=Singleton): if not private_id: return "0" * 40 - return hashlib.sha1(private_id).hexdigest() + h = hashlib.sha1(private_id.encode()) + return h.hexdigest() @property def secret_id(self): @@ -217,7 +219,8 @@ class System(object, metaclass=Singleton): if os.path.exists(SECRET_ID_FILE): return read_from_file(SECRET_ID_FILE) - return hashlib.sha1(self._unique_id).hexdigest() + h = hashlib.sha1(self._unique_id.encode()) + return h.hexdigest() @property def _unique_id(self):