17 lines
446 B
Python
17 lines
446 B
Python
|
import hashlib
|
||
|
|
||
|
# Get user inputs for nonce and difficulty
|
||
|
nonce = input("Enter the nonce: ")
|
||
|
difficulty = int(input("Enter the difficulty (number of leading zeros): "))
|
||
|
|
||
|
def sha256(message):
|
||
|
return hashlib.sha256(message.encode()).hexdigest()
|
||
|
|
||
|
solution = 0
|
||
|
while True:
|
||
|
hash_result = sha256(nonce + str(solution))
|
||
|
if hash_result.startswith('0' * difficulty):
|
||
|
print("Solution found:", solution)
|
||
|
break
|
||
|
solution += 1
|