PoW/PoW.py

14 lines
274 B
Python

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