🚨 Fixed linter errors
This commit is contained in:
@@ -125,11 +125,5 @@ def check_hashcash(data: str, input_data: str, claim_in: Optional[str] = "19") -
|
|||||||
version, claim, _date, res, ext, _rand, _counter = data.split(":")
|
version, claim, _date, res, ext, _rand, _counter = data.split(":")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
try:
|
some_error = [version == "1", claim == claim_in, res == input_data, ext == ""]
|
||||||
assert version == "1"
|
return all(el is True for el in some_error)
|
||||||
assert claim == claim_in
|
|
||||||
assert res == input_data
|
|
||||||
assert ext == ""
|
|
||||||
return True
|
|
||||||
except AssertionError:
|
|
||||||
return False
|
|
||||||
|
|||||||
@@ -96,7 +96,9 @@ def _mint(challenge, bits):
|
|||||||
hex_digits = int(ceil(bits / 4.0))
|
hex_digits = int(ceil(bits / 4.0))
|
||||||
zeros = "0" * hex_digits
|
zeros = "0" * hex_digits
|
||||||
while 1:
|
while 1:
|
||||||
digest = hashlib.sha1((challenge + hex(counter)[2:]).encode(), usedforsecurity=False).hexdigest()
|
digest = hashlib.sha1(
|
||||||
|
(challenge + hex(counter)[2:]).encode(), usedforsecurity=False
|
||||||
|
).hexdigest() # skipcq: PYL-E1123, PTC-W1003
|
||||||
if digest[:hex_digits] == zeros:
|
if digest[:hex_digits] == zeros:
|
||||||
tries[0] = counter
|
tries[0] = counter
|
||||||
return hex(counter)[2:]
|
return hex(counter)[2:]
|
||||||
@@ -137,7 +139,9 @@ def check(stamp, resource=None, bits=None, check_expiration=None, ds_callback=No
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
hex_digits = int(floor(bits / 4))
|
hex_digits = int(floor(bits / 4))
|
||||||
return hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
return (
|
||||||
|
hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
||||||
|
) # skipcq: PYL-E1123, PTC-W1003
|
||||||
elif stamp.startswith("1:"): # Version 1
|
elif stamp.startswith("1:"): # Version 1
|
||||||
try:
|
try:
|
||||||
claim, date, res, _ext, _rand, _counter = stamp[2:].split(":")
|
claim, date, res, _ext, _rand, _counter = stamp[2:].split(":")
|
||||||
@@ -155,7 +159,9 @@ def check(stamp, resource=None, bits=None, check_expiration=None, ds_callback=No
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
hex_digits = int(floor(int(claim) / 4))
|
hex_digits = int(floor(int(claim) / 4))
|
||||||
return hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
return (
|
||||||
|
hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
||||||
|
) # skipcq: PYL-E1123, PTC-W1003
|
||||||
else: # Unknown ver or generalized hashcash
|
else: # Unknown ver or generalized hashcash
|
||||||
if type(bits) is not int:
|
if type(bits) is not int:
|
||||||
return True
|
return True
|
||||||
@@ -163,4 +169,6 @@ def check(stamp, resource=None, bits=None, check_expiration=None, ds_callback=No
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
hex_digits = int(floor(bits / 4))
|
hex_digits = int(floor(bits / 4))
|
||||||
return hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
return (
|
||||||
|
hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
||||||
|
) # skipcq: PYL-E1123, PTC-W1003
|
||||||
|
|||||||
Reference in New Issue
Block a user