Blockchain Concepts

How Hashing Links Blocks Together

How a hash works as a digital fingerprint, and how including each block's fingerprint in the next one makes a record tamper-evident.

On this page
  1. What a hash is
  2. The properties that matter
  3. From fingerprint to chain
  4. Hashing many entries at once
  5. Hashing as the puzzle in proof of work
  6. Where hashing shows up elsewhere
  7. What hashing does not do
  8. The takeaway

What a hash is

A hash function takes any amount of data, from a single word to a whole file, and produces a short, fixed-length string of characters called a hash or digest. You can think of it as a digital fingerprint. A widely used function in this family produces a result 256 bits long, usually written as 64 hexadecimal characters, whether the input is one letter or a large video.

The same input always gives the same output. That makes the hash useful for checking data: if two copies of a file have the same hash, they are, for practical purposes, identical.

The properties that matter

Cryptographic hash functions are designed to have several properties.

  • Deterministic. Hashing the same data twice gives the same result.
  • Fast to compute. Producing a hash from data is quick.
  • One-way. Given only a hash, there is no practical way to work backward and recover the original data. Short or predictable inputs are an exception, since a person can guess candidates and hash them to compare.
  • Sensitive to small changes. Changing a single character in the input produces a hash that looks completely unrelated. Nothing about the new hash hints at how small the edit was.
  • Collision resistant. It should be impractical to find two different inputs that produce the same hash.

These properties together are what make a hash a trustworthy fingerprint. Older functions that were later found to be weak on collision resistance have been retired from security uses, which is why the choice of function matters.

From fingerprint to chain

A block in a blockchain contains a batch of entries, some descriptive data such as a timestamp, and the hash of the previous block. The block’s own hash is then calculated from all of that, including the previous hash.

Picture three blocks in a row, labeled A, B and C. Block B stores the hash of A. Block C stores the hash of B. Because B’s hash was computed using A’s hash as part of its input, and C’s from B’s, each fingerprint depends on everything before it.

Now suppose someone secretly edits an entry in block A. A’s hash changes completely. Block B still holds the old hash of A, so it no longer matches, and the link is broken. To hide the edit, the tamperer would need to recompute B, then C, and every block after it. Even then, other copies of the ledger held by other participants would still show the original hashes, so the mismatch would be noticed.

This is what people mean by tamper-evident. The chain does not stop someone from changing data; it makes the change visible and makes hiding it increasingly expensive as more blocks are added on top.

Hashing many entries at once

A block can hold thousands of entries, and checking one of them should not require rehashing the whole block. A common solution is a Merkle tree. Entries are hashed individually, the hashes are paired and hashed again, and the process repeats until a single hash, the root, represents everything in the block. Only the root needs to be stored in the block header.

To prove that one entry is included, you only need the hashes along its path to the root, a small fraction of the data. This helps lightweight devices verify records without downloading everything.

Hashing as the puzzle in proof of work

Some networks also use hashing as the basis of a competition. Participants repeatedly change a small number in the block and recompute the hash, looking for a result that meets a difficulty target, such as one that begins with a certain number of zeros. Because the function is unpredictable, the only way to find a qualifying result is by trying many times. The more attempts needed, the more work the block represents. This is the idea behind the proof of work approach mentioned in the discussion of consensus mechanisms.

Where hashing shows up elsewhere

Hashes are not unique to blockchains. Software downloads often list a hash so users can check that a file was not corrupted or swapped. Well-designed websites store a salted hash of your password rather than the password itself, so a database leak does not directly reveal it, which is part of good practice alongside password managers. Hashing differs from message encryption, because encryption is meant to be reversed by someone holding the right key, whereas a hash is not meant to be reversed at all.

What hashing does not do

It helps to be clear about the limits.

  • It does not prove the data is true. A hash shows that data has not changed since it was hashed, not that it was accurate in the first place.
  • It does not hide data by itself. If the input is guessable, such as a short list of possible values, a hash can be matched by trying them all.
  • It does not guarantee who wrote it. Linking a record to a person needs digital signatures as well.
  • It is not permanent protection. If a hash function is later found to be weak, systems relying on it need to move to a stronger one. Researchers also study how future quantum machines could affect some cryptography, a topic usually discussed under post-quantum cryptography; hash functions are generally considered less affected than some other tools, though the details are still being studied.

The takeaway

A hash is a compact fingerprint that changes completely when its input changes even slightly. Placing each block’s fingerprint inside the next block creates a chain in which every link depends on all that came before. That simple structure is the reason an altered history stands out, and it is the foundation on which the rest of a blockchain is built.

The complete guide to blockchain concepts

Blockchain Explained Without the Hype
Read the guide

Keep exploring

Guides from other topics

All topics →