【发布时间】:2021-01-22 18:03:12
【问题描述】:
import hashlib
previous_proof = 0
new_proof = 0
check_proof = False
while check_proof is False:
hash_operation = hashlib.sha256(str(new_proof**2 - previous_proof**2).encode()).hexdigest()
if hash_operation[:4] == '0000':
check_proof = True
else:
new_proof+=1
print(hash_operation)
print( new_proof)
我制作了这个脚本,用于在 sha256 中查找以“0000”开头的字符串。 谁能解释我为什么如果我输入 '000000' 而不是 '0000' 需要更多时间才能找到字符串? 它应该花费更少的时间,因为我一开始有更多的零,对吧?
【问题讨论】:
-
掷骰子直到连续获得 3 个六点可能需要一段时间。掷骰子直到连续获得 6 个六点通常需要更长的时间。