Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from hashlib import sha256
- class BlockHash:
- __blockPos = 0
- __prev_hash = 0
- __hash = 0
- __client = "Cli: " + str(__blockPos)
- __client_msg = ""
- def __init__(self, pos, prev_hash, blhash, client, msg):
- self.__blockPos = pos
- self.__prev_hash = prev_hash
- self.__hash = blhash
- self.__client = "Cli: " + str(client)
- self.__client_msg = str(msg)
- def block_info_hash(self):
- info = str(self.__blockPos) + str(self.__prev_hash) + str(self.__hash) + self.__client + self.__client_msg
- info = info.encode()
- return sha256(info).hexdigest()
- def get_prev_hash(self):
- return self.__hash
- def show_data(self):
- print(str(self.__blockPos))
- print(str(self.__prev_hash))
- print(str(self.__hash))
- print(self.__client + self.__client_msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement