The Relationship Between Blockchain and Hash Values
In the previous chapter, we mentioned that each block can have a hash value calculated from its content.
So, what exactly is a blockchain? And how is it related to each block’s hash value?
The core structure of a blockchain lies in this principle:
Each block includes the hash of the previous block and combines it with its own data to calculate its own hash.
For example:
The second block contains a field called "Previous Block Hash",
which stores the hash value of the first block.
Try clicking the button below the second block to calculate its hash.
Now try changing the data in the first block.
Observe whether the "Previous Block Hash" field in the second block changes.
Then recalculate the second block's hash and see if it changes too.
Next, let's explore the advantages of this design.
Suppose we already have two blocks.
If the "Data" in the first block is maliciously altered—
for example, by adding or removing just a single character—
then the hash value of the first block will change.
As a result, the second block’s previously calculated block hash will now become incorrect,
effectively breaking the link between the two blocks in the blockchain.
Therefore, by including the hash of the previous block in each block's calculation,
the system greatly increases the difficulty of tampering with the data.
If someone wants to alter the first block, they would also have to modify all subsequent linked blocks.
Now, click the button below to try creating more blocks
and observe how they are connected together!