from hashlib import sha256
#pow 工作量证明机制
x = 1
y = 2
# f'{x*y}' x*y 的结果转换成字符串
# encode 默认是utf-8
#a = sha256(f'{x*y}'.encode()).hexdigest()[-5:]
# a ==b的时候算出一个hash是00000结尾的,那么就拿到这个区块
b = "00000"
while sha256(f'{x*y}'.encode()).hexdigest()[-5:] != b:
y += 1
print(y,sha256(f'{x*y}'.encode()).hexdigest()[-5:])
print("y={}时刻,y求解".format(y))
简易pow工作量证明机制机制实现
猜你喜欢
转载自blog.csdn.net/ThrallOtaku/article/details/80029720
今日推荐
周排行