From a47fa095cfe07d32fdbf8cd483b39faca4df1f95 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 6 Sep 2017 06:44:52 +0200 Subject: [PATCH 1/2] from __future__ import print_function `from __future__ import print_function` to bring the print function from Python 3 into Python 2.6 and 2.7. Properly deals with comma separated values in print() function. --- code/key-to-address-ecc-example.py | 1 + 1 file changed, 1 insertion(+) diff --git a/code/key-to-address-ecc-example.py b/code/key-to-address-ecc-example.py index 742ffe71..2a206535 100644 --- a/code/key-to-address-ecc-example.py +++ b/code/key-to-address-ecc-example.py @@ -1,3 +1,4 @@ +from __future__ import print_function import bitcoin # Generate a random private key From b8a0cddb9f745594458840fef6fbdc44fbcb520f Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 6 Sep 2017 07:23:23 +0200 Subject: [PATCH 2/2] from __future__ import print_function --- code/hash_example.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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)