Improve syntax
parent
e7c826d4c6
commit
d4ae6255d6
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue