Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. from hashlib import sha256
  2.  
  3.  
  4. class BlockHash:
  5. __blockPos = 0
  6. __prev_hash = 0
  7. __hash = 0
  8. __client = "Cli: " + str(__blockPos)
  9. __client_msg = ""
  10.  
  11. def __init__(self, pos, prev_hash, blhash, client, msg):
  12. self.__blockPos = pos
  13. self.__prev_hash = prev_hash
  14. self.__hash = blhash
  15. self.__client = "Cli: " + str(client)
  16. self.__client_msg = str(msg)
  17.  
  18. def block_info_hash(self):
  19. info = str(self.__blockPos) + str(self.__prev_hash) + str(self.__hash) + self.__client + self.__client_msg
  20. info = info.encode()
  21. return sha256(info).hexdigest()
  22.  
  23. def get_prev_hash(self):
  24. return self.__hash
  25.  
  26. def show_data(self):
  27. print(str(self.__blockPos))
  28. print(str(self.__prev_hash))
  29. print(str(self.__hash))
  30. print(self.__client + self.__client_msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement