# example of iterating a nonce in a hashing algorithm's input

from __future__ import print_function
import hashlib

text = "Hello 56600 Peeps!"
target = 0x0000123456789ABCDEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
print("Target: ", format(target, '064x'))

# iterate nonce from 0 to 24
for nonce in range(10000000):
    # add the nonce to the end of the text
    input_data = text + str(nonce)

    # calculate the SHA-256 hash of the input (text+nonce)
    hash_data = hashlib.sha256(input_data.encode('utf-8')).hexdigest()
    ihash = int(hash_data,16)

    match = ihash < target # ???

    # show the input and hash result
    if match:
        print("Nonce: ", nonce, ": ", input_data, '=>', hash_data, " Match? ",match, "Good Grief!!! I'm RICH!!!!")
    else:
        print("Nonce: ", nonce, ": ", input_data, '=>', hash_data, " Match? ",match, " damnit!!!")

