1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-11-25 01:18:18 +00:00

Merge pull request #372 from cclauss/patch-3

from __future__ import print_function
This commit is contained in:
Will Binns 2017-11-18 07:39:50 -06:00 committed by GitHub
commit d5e2316438
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -1,18 +1,18 @@
# example of iterating a nonce in a hashing algorithm's input # example of iterating a nonce in a hashing algorithm's input
from __future__ import print_function
import hashlib import hashlib
text = "I am Satoshi Nakamoto" text = "I am Satoshi Nakamoto"
# iterate nonce from 0 to 19 # 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 # 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) # 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 # show the input and hash result
print(input, '=>', hash) print(input, '=>', hash)

View File

@ -1,3 +1,4 @@
from __future__ import print_function
import bitcoin import bitcoin
# Generate a random private key # Generate a random private key