🚨 Fixed linter errors
This commit is contained in:
@@ -97,8 +97,8 @@ def _mint(challenge, bits):
|
||||
zeros = "0" * hex_digits
|
||||
while 1:
|
||||
digest = hashlib.sha1(
|
||||
(challenge + hex(counter)[2:]).encode(), usedforsecurity=False
|
||||
).hexdigest() # skipcq: PYL-E1123, PTC-W1003
|
||||
(challenge + hex(counter)[2:]).encode(), usedforsecurity=False # skipcq: PYL-E1123, PTC-W1003
|
||||
).hexdigest()
|
||||
if digest[:hex_digits] == zeros:
|
||||
tries[0] = counter
|
||||
return hex(counter)[2:]
|
||||
@@ -140,8 +140,10 @@ def check(stamp, resource=None, bits=None, check_expiration=None, ds_callback=No
|
||||
else:
|
||||
hex_digits = int(floor(bits / 4))
|
||||
return (
|
||||
hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
||||
) # skipcq: PYL-E1123, PTC-W1003
|
||||
hashlib.sha1((stamp).encode(), usedforsecurity=False)
|
||||
.hexdigest() # skipcq: PYL-E1123, PTC-W1003
|
||||
.startswith("0" * hex_digits)
|
||||
)
|
||||
elif stamp.startswith("1:"): # Version 1
|
||||
try:
|
||||
claim, date, res, _ext, _rand, _counter = stamp[2:].split(":")
|
||||
@@ -160,7 +162,9 @@ def check(stamp, resource=None, bits=None, check_expiration=None, ds_callback=No
|
||||
else:
|
||||
hex_digits = int(floor(int(claim) / 4))
|
||||
return (
|
||||
hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
||||
hashlib.sha1((stamp).encode(), usedforsecurity=False)
|
||||
.hexdigest() # skipcq: PYL-E1123, PTC-W1003
|
||||
.startswith("0" * hex_digits)
|
||||
) # skipcq: PYL-E1123, PTC-W1003
|
||||
else: # Unknown ver or generalized hashcash
|
||||
if type(bits) is not int:
|
||||
@@ -170,5 +174,7 @@ def check(stamp, resource=None, bits=None, check_expiration=None, ds_callback=No
|
||||
else:
|
||||
hex_digits = int(floor(bits / 4))
|
||||
return (
|
||||
hashlib.sha1((stamp).encode(), usedforsecurity=False).hexdigest().startswith("0" * hex_digits)
|
||||
hashlib.sha1((stamp).encode(), usedforsecurity=False)
|
||||
.hexdigest() # skipcq: PYL-E1123, PTC-W1003
|
||||
.startswith("0" * hex_digits)
|
||||
) # skipcq: PYL-E1123, PTC-W1003
|
||||
|
||||
Reference in New Issue
Block a user