pow-site/templates/challenge.html

47 lines
1.3 KiB
HTML
Raw Normal View History

2024-10-22 14:05:39 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Proof of Work Challenge</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<div class="container">
<h1>Proof of Work Challenge</h1>
<p><strong>Nonce:</strong> {{ nonce }}</p>
<p><strong>Difficulty:</strong> {{ difficulty }}</p>
<h2>Instructions</h2>
<p>To solve the Proof of Work challenge, run the following Python script locally with the provided nonce:</p>
<div class="code-box">
<pre>
import hashlib
nonce = "{{ nonce }}"
difficulty = {{ difficulty }}
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
</pre>
</div>
<p>Once you've found the solution, enter it below:</p>
<form action="/verify" method="post">
<label for="solution">Solution:</label>
<input type="text" id="solution" name="solution" required>
<button type="submit">Verify</button>
</form>
</div>
</body>
</html>