pow-site/solve.py

17 lines
446 B
Python
Raw Normal View History

2024-10-22 14:05:39 +00:00
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