diff --git a/src/apiservers/private/__init__.py b/src/apiservers/private/__init__.py index ca7587df..a7c07bd6 100644 --- a/src/apiservers/private/__init__.py +++ b/src/apiservers/private/__init__.py @@ -76,10 +76,7 @@ class PrivateAPI: logger.error("client password needs to be set") return False try: - if not hmac.compare_digest(self.clientToken, token): - return False - else: - return True + return hmac.compare_digest(self.clientToken, token) except TypeError: return False diff --git a/src/utils/reconstructhash.py b/src/utils/reconstructhash.py index ae50c0b2..c50840cb 100644 --- a/src/utils/reconstructhash.py +++ b/src/utils/reconstructhash.py @@ -21,7 +21,6 @@ def reconstruct_hash(hex_hash, length=64): return hex_hash.zfill(length) def deconstruct_hash(hex_hash): - new_hash = '' ret_bytes = False try: hex_hash = hex_hash.decode() @@ -29,15 +28,10 @@ def deconstruct_hash(hex_hash): except AttributeError: pass - c = 0 - for x in hex_hash: - if x == '0': - c += 1 - else: - break - new_hash = hex_hash[c:] + num_zeroes = hex_hash.count('0') + new_hash = hex_hash[num_zeroes:] if ret_bytes: - new_hash = new_hash.encode() + return new_hash \ No newline at end of file