Duke's Fuqua School of Business



HYPERLINK "" # Simple Hashing Program in Python__author__ = ''import randomimport hashlibimport timeptarget = '0000' # Put the target number of leading zeros you want hereheader = 'Cam Harvey is Satoshi' # I am hashing my name + noncenonce = 1 # Nonce starts at 1 and increments until target hit p = 'abc'start_t = time.time()while p != ptarget: testval = str.encode(header + str(nonce)) hash_object = hashlib.sha256(testval) hex_dig = hash_object.hexdigest() nonce += 1 p = hex_dig[0:len(ptarget)]secs = time.time() - start_tmins, secs = divmod(secs, 60)hours, mins = divmod(mins, 60)print(p, nonce-1)print('%02d:%02d:%05.2f' % (hours, mins, secs))print(hex_dig)Other Py resources: ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download