PoW/PoW.py
2023-10-09 19:53:35 +03:00

14 lines
285 B
Python

import hashlib
def check(data, proof, complexity=1, f=hashlib.sha256):
zeros="0"*complexity
hash=f((proof+data).encode())
hashdata=hash.hexdigest()
b=0
for a in hashdata:
if a=="0":
b+=1
else:
break
return b>=complexity