Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. def proof_of_work(header, difficulty_bits):
  2. #{
  3.  
  4. # Obliczanie celu
  5. target = 2 ** (256-difficulty_bits)
  6.  
  7. for nonce in xrange(max_nonce):
  8. #{
  9. hash_result = hashlib.sha256(str(header)+str(nonce)).hexdigest()
  10.  
  11. # Sprawdzanie, czy wynik jest prawidłowy (mniejszy od celu)
  12. if long(hash_result, 16) < target:
  13. #{
  14. print "Powodzenie dla wartości nonce %d" % nonce
  15. print "Skrót to %s" % hash_result
  16. return (hash_result,nonce)
  17. #}
  18. #}
  19.  
  20. print "Niepowodzenie po %d (max_nonce) próbach" % nonce
  21. return nonce
  22. #}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement