Improve syntax

This commit is contained in:
0Gitnick 2019-11-26 22:11:08 -06:00
parent e7c826d4c6
commit d4ae6255d6
2 changed files with 4 additions and 13 deletions

View File

@ -76,10 +76,7 @@ class PrivateAPI:
logger.error("client password needs to be set") logger.error("client password needs to be set")
return False return False
try: try:
if not hmac.compare_digest(self.clientToken, token): return hmac.compare_digest(self.clientToken, token)
return False
else:
return True
except TypeError: except TypeError:
return False return False

View File

@ -21,7 +21,6 @@ def reconstruct_hash(hex_hash, length=64):
return hex_hash.zfill(length) return hex_hash.zfill(length)
def deconstruct_hash(hex_hash): def deconstruct_hash(hex_hash):
new_hash = ''
ret_bytes = False ret_bytes = False
try: try:
hex_hash = hex_hash.decode() hex_hash = hex_hash.decode()
@ -29,15 +28,10 @@ def deconstruct_hash(hex_hash):
except AttributeError: except AttributeError:
pass pass
c = 0 num_zeroes = hex_hash.count('0')
for x in hex_hash: new_hash = hex_hash[num_zeroes:]
if x == '0':
c += 1
else:
break
new_hash = hex_hash[c:]
if ret_bytes: if ret_bytes:
new_hash = new_hash.encode() new_hash = new_hash.encode()
return new_hash return new_hash