]> git.ipfire.org Git - oddments/fireinfo.git/commitdiff
system: Pass any data into hashlib as bytes
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 7 May 2021 11:07:05 +0000 (11:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 7 May 2021 11:07:05 +0000 (11:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/fireinfo/system.py

index 9923ff664dc2bd2a38c9604404a08785f49ea93d..63b67fc53169c5ebae1e98b2c731dcfcc1ab66b1 100644 (file)
@@ -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):