Merge pull request #531 from koshikraj/code-fix

fixed hashlib library error for python3
pull/636/head
Will Binns 5 years ago committed by GitHub
commit ee6131abf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,7 +12,7 @@ for nonce in range(20):
input_data = text + str(nonce)
# calculate the SHA-256 hash of the input (text+nonce)
hash_data = hashlib.sha256(input_data).hexdigest()
hash_data = hashlib.sha256(input_data.encode()).hexdigest()
# show the input and hash result
print(input_data, '=>', hash_data)

@ -19,7 +19,7 @@ def proof_of_work(header, difficulty_bits):
target = 2 ** (256 - difficulty_bits)
for nonce in xrange(max_nonce):
hash_result = hashlib.sha256(str(header) + str(nonce)).hexdigest()
hash_result = hashlib.sha256((str(header) + str(nonce)).encode()).hexdigest()
# check if this is a valid result, below the target
if long(hash_result, 16) < target:

Loading…
Cancel
Save