Created
May 3, 2025 14:57
-
-
Save nloadholtes/86c435f0b2205d2727715f65d40a6d14 to your computer and use it in GitHub Desktop.
I wanted to try making a simple proof of work program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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