diff --git a/code/hash_example.py b/code/hash_example.py index 289628b0..3f6e6771 100644 --- a/code/hash_example.py +++ b/code/hash_example.py @@ -1,18 +1,18 @@ - # example of iterating a nonce in a hashing algorithm's input +from __future__ import print_function import hashlib - + text = "I am Satoshi Nakamoto" # iterate nonce from 0 to 19 -for nonce in range(20): - +for nonce in range(20): + # add the nonce to the end of the text - input = text + str(nonce) - + input = text + str(nonce) + # calculate the SHA-256 hash of the input (text+nonce) - hash = hashlib.sha256(input).hexdigest() - + hash = hashlib.sha256(input).hexdigest() + # show the input and hash result print(input, '=>', hash)