Skip to content

Instantly share code, notes, and snippets.

@nloadholtes
Created May 3, 2025 14:57
Show Gist options
  • Save nloadholtes/86c435f0b2205d2727715f65d40a6d14 to your computer and use it in GitHub Desktop.
Save nloadholtes/86c435f0b2205d2727715f65d40a6d14 to your computer and use it in GitHub Desktop.
I wanted to try making a simple proof of work program
from hashlib import sha256
import time
def hasher(challenge_phrase:str, zero_count: int =0 ):
nonce = 0
zeros = 0
zero_string = "0" * zero_count
while zeros != zero_count:
h = sha256(str(challenge_phrase + str(nonce)).encode("utf8"))
digest = h.hexdigest()
if digest[:zero_count] == zero_string:
print(digest)
break
nonce += 1
return nonce
CHALLENGE = "1234567"
for x in range(7):
print(hasher(CHALLENGE, x))
print(time.asctime())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment