Last active
November 8, 2021 22:48
-
-
Save perymerdeka/54af33e9fb538e1fa62fc0801affb977 to your computer and use it in GitHub Desktop.
Class Blockchain
This file contains 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
from hashlib import sha256 | |
class Blockchain: | |
def __init__(self, prev_hash: str, transaction_list: list): | |
self.prev_hash = prev_hash | |
self.transaction_list = transaction_list | |
# block data and concate strings | |
self.block_data = " - ".join(transaction_list) + " - " + prev_hash | |
self.block_hash = sha256(self.block_data.encode()).hexdigest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment