What is a hash, and why do blockchains use them?
A hash function turns data of almost any size into a short code of fixed length, called a digest.1,2 Change even one bit of the data and the digest changes completely, so anyone can check that data has not been altered.2
A fingerprint for data
A hash function takes some data and turns it into a short code of fixed length.1 That code is called a message digest, or just a digest.2 The data can be almost anything: a file, some text or an image.2
Think of the digest as a fingerprint for the data. The same data always gives the same digest, so anyone can hash it again and compare the results.2 If they match, the data has not changed.2
Small change, big difference
Even the smallest change to the input, such as one bit, gives a completely different digest.2 The US standard for these functions says any change to a message will, with very high probability, give a different digest.3
Three safety properties
Hash functions used for security are built to have three properties.2,1 NIST's example of how strong they are: finding a SHA-256 collision would take the whole 2015 Bitcoin network about 36 trillion years.2
- One-way. Given a digest, it is computationally infeasible to work out an input that produces it. This is called preimage resistance.2
- Second-preimage resistant. Given one input, you can't find a different input with the same digest.2
- Collision resistant. You can't find any two different inputs that give the same digest.2
SHA-256
SHA-256 is a hash function used by many blockchains.2 Its digest is 256 bits long, usually shown as a string of 64 characters using the digits 0 to 9 and the letters a to f.2 The US standard FIPS 180-4 specifies it.3,2
There are about 10 to the power of 77 possible SHA-256 digests.2 Two inputs with the same digest must exist in theory, but finding one would take about 2 to the power of 128 tries on average.2 The 2015 Bitcoin network made about 300 quadrillion hashes a second, which is how NIST reached its 36 trillion years.2
Bitcoin uses SHA-256. Ethereum uses a different hash function, called Keccak-256.2 Keccak won a NIST competition to create the SHA-3 standard.2
What blockchains use hashes for
Blockchains use hashes for many jobs.2
- Giving things a unique ID. In Bitcoin, a transaction's ID is the hash of the signed transaction.2,4
- Locking in a block's contents, by storing a hash of its data in the block's header.2
- Linking each block to the one before it, as the next lesson explains.2
- Making addresses.2
Hashes can age
NIST deprecated an older function, SHA-1, in 2011, which means it advised against using it. It disallowed SHA-1 for digital signatures at the end of 2013.1 NIST also notes that if a flaw were found in SHA-256, blockchains using it would need a hard fork to switch to a new function.2 Lesson 6 explains forks.
- Hash Functions (project page). US National Institute of Standards and Technology, Computer Security Resource Center.
- NIST IR 8202: Blockchain Technology Overview. US National Institute of Standards and Technology (Yaga, Mell, Roby, Scarfone), October 2018.
- FIPS 180-4: Secure Hash Standard (SHS). US National Institute of Standards and Technology, August 2015.
- Bitcoin developer guide: Block chain. Bitcoin developer documentation (developer.bitcoin.org).
General education built from the publicly available sources listed above. Not financial, legal, tax or investment advice. Naming a company, project or regulator is not an endorsement either way. Last checked 2026-10-22. Terms and disclaimer.