We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import hashlib
def hashGenerator(data): result=hashlib.sha256(data.encode()) return result.hexdigest()
class Block: def init(self,data,hash,prev_hash): self.data=data self.hash=hash self.prev_hash=prev_hash
class Blockchain: def init(self): hashLast=hashGenerator('gen_last') hashStart=hashGenerator('gen_hash')
genesis=Block('gen-data',hashStart,hashLast) self.chain=[genesis] def add_block(self,data): prev_hash=self.chain[-1].hash hash=hashGenerator(data+prev_hash) block=Block(data,hash,prev_hash) self.chain.append(block)
bc=Blockchain() bc.add_block('1') bc.add_block('2') bc.add_block('3')
for block in bc.chain: print(block.dict)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
import hashlib
def hashGenerator(data):
result=hashlib.sha256(data.encode())
return result.hexdigest()
class Block:
def init(self,data,hash,prev_hash):
self.data=data
self.hash=hash
self.prev_hash=prev_hash
class Blockchain:
def init(self):
hashLast=hashGenerator('gen_last')
hashStart=hashGenerator('gen_hash')
bc=Blockchain()
bc.add_block('1')
bc.add_block('2')
bc.add_block('3')
for block in bc.chain:
print(block.dict)
The text was updated successfully, but these errors were encountered: