Die Block-Chain ist eine dezentrale Datenbank, welche unveränderlich ist.
Quelle: https://de.wikipedia.org/wiki/Blockchain
Quelle: https://aws.amazon.com/de/what-is/blockchain/?aws-products-all.sort-by=item.additionalFields.productNameLowercase&aws-products-all.sort-order=asc (unter der Überschrift "Wie funktioniert die Blockchain?")
import hashlib
# hashed mit md5
def hash(data):
return hashlib.md5(data.encode()).hexdigest()
# BitCoin Setup
genesis_block = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
difficulty = 2 # hash has to start with difficulty zeros
# Transaktionen Transaktionen Transaktionen
transaktionen = []
transaktionen.append("jannis->takumi:1")
transaktionen.append("corvin->herrTempel:10000")
# ...
# Block zusammenbauen
new_block = hash(genesis_block) + str(transaktionen)
# mining second block
print("start mining")
hashed = ""
nonce = -1
while not hashed.startswith(difficulty * "0"):
nonce = nonce + 1
hashed = hash(str(nonce) + new_block)
print("block hash", hashed, " with nonce:", nonce)
print("mining successful with", nonce)