Created
January 9, 2018 08:35
-
-
Save bourdeau/d2d15bf5c1e4b7d4b3eea5d71388c8d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import hashlib | |
| difficulty = 8 | |
| block = "alice:0.0001:bob:whatever" | |
| nonce = 0 | |
| zeros = "" | |
| for i in range(difficulty): | |
| zeros += "0" | |
| while True: | |
| hash_object = hashlib.sha256('{}:{}'.format(block, nonce)) | |
| hash = hash_object.hexdigest() | |
| if hash.startswith(zeros): | |
| print('Difficulty: {}'.format(difficulty)) | |
| print('Hash: {}'.format(hash)) | |
| print('Nonce: {}'.format(nonce)) | |
| sys.exit(0) | |
| nonce += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment