Skip to content
IntermediateLook up a term

What is a hash function?

Author
CRYPTO PORT Editorial
Published
Updated
Reading time
4 min

In short

A hash function turns input of any length into a fixed-length output. Change one character of the input and the output is completely different, which makes it a reliable way to detect tampering. That property is the foundation of a blockchain's integrity.

Key points

  • The same input always yields the same output
  • You cannot reverse the output back to the input
  • A tiny input change scrambles the whole output
  • It is the link that chains blocks together

Definition

A one-way computation that maps data of any size to a fixed-size value, reproducible from the same input but not practically reversible.

Bitcoin uses SHA-256: whether the input is one character or one terabyte, the output is always 256 bits. 'hello' and 'Hello' produce outputs with nothing in common — the avalanche effect, which is what makes hidden edits impractical.

Each block on a chain includes the hash of the block before it. Alter a single byte in an old block and its hash changes, breaking the link the next block relies on. Unless every subsequent block is recomputed, the inconsistency stays visible. That is what people mean by immutability.

Proof-of-Work mining is another use of the same function. Miners vary part of the input by brute force until the output meets a condition, such as starting with a run of zeros. Finding an answer takes enormous effort; checking a proposed answer takes one computation.

Watch out for

  • · Hashing is not encryption; there is no decryption step
  • · Low-entropy inputs such as passwords can still be guessed by brute force

Related coins

Read next

Crypto quizzes

Answer a few questions and get your result instantly.

Start