← Hash function

Version 1

Dec 3, 2026. Compare with the current version · Version history

A hash function is a function that turns data of any length into a short, fixed-length value, designed so that the value works as a digital fingerprint of the data.[6]

What a hash function does

NIST's glossary gives the core definition as a function on bit strings in which the length of the output is fixed.[6] The standards that NIST approves for security use take a message of nearly any size and produce a condensed representation called a message digest.[1] The output is also called a hash or hash value.

A cryptographic hash function is one that is built to resist attack, and NIST's glossary lists the properties expected of an approved one:[6]

  • One-way (preimage resistance): it is computationally infeasible to find an input that maps to a new, pre-specified output.[6]
  • Collision-resistant: it is computationally infeasible to find two different inputs that map to the same output.[6]

A further property, second-preimage resistance, appears in NIST's definitions of approved hash functions alongside the other two.[6]

The use that gives hashing its place in security follows from these properties. The Secure Hash Standard states that any change to a message will, with very high probability, produce a different message digest, which lets a receiver determine whether the message's integrity has been preserved.[1] The same standard names digital signatures, message authentication codes and the generation of random numbers or bits as uses of that property.[1]

The SHA families

NIST specifies its approved hash algorithms in two standards.[3]

FIPS 180-4, the Secure Hash Standard (August 2015) covers SHA-1 and the SHA-2 family: SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224 and SHA-512/256.[1][3] The standard describes each algorithm in two stages: preprocessing, which pads the message and splits it into fixed-size blocks, and hash computation, which works through those blocks to produce the digest.[1] The algorithms differ in digest size and in block and word size, as the standard's table shows:[1]

AlgorithmBlock size (bits)Word size (bits)Digest size (bits)
SHA-151232160
SHA-22451232224
SHA-25651232256
SHA-384102464384
SHA-512102464512
SHA-512/224102464224
SHA-512/256102464256

The standard says the algorithms differ most in the security strength they provide for the data being hashed.[1]

FIPS 202, the SHA-3 Standard was also released in August 2015. It specifies the SHA-3 family, based on the KECCAK algorithm that NIST selected in its SHA-3 Cryptographic Hash Algorithm Competition.[4] The family has four hash functions (SHA3-224, SHA3-256, SHA3-384 and SHA3-512) and two extendable-output functions, SHAKE128 and SHAKE256, and the standard supplements SHA-1 and SHA-2 rather than replacing them.[4] As of September 2026, NIST's page states that only the four fixed-length SHA-3 algorithms are approved as hash algorithms, and that the extendable-output functions can be used as hash functions subject to additional security considerations.[3]

When a hash function is broken: SHA-1

Collision resistance can fail. NIST deprecated SHA-1 in 2011 and disallowed it for digital signatures at the end of 2013, and in December 2022 published a plan to transition away from its remaining limited use.[3]

On 23 February 2017, researchers at CWI Amsterdam and Google announced the first real SHA-1 collision, which they called SHAttered: two visibly different PDF files with the same SHA-1 value, while their SHA-256 values differ.[5] They put the cost at about nine quintillion SHA-1 computations, roughly 6,500 CPU-years and 110 GPU-years, and said it was thousands of times faster than brute force and expected to become cheaper over time.[5]

Hash functions in Bitcoin

Bitcoin's design paper uses hashing in three places.

  • Proof of work. The paper's proof-of-work scans for a value that, when hashed, "such as with SHA-256", gives a hash that begins with a required number of zero bits.[2] The average work needed grows exponentially with the number of zero bits, yet it can be verified by executing a single hash.[2] A block's proof is found by incrementing a nonce in the block until its hash has the required zero bits, after which the block cannot be changed without redoing the work.[2] How hard the target is set is covered in Mining difficulty and the network's total rate of hashing in Hash rate.
  • Chaining. Each timestamp includes the previous timestamp in its hash, forming a chain, and each block carries the hash of the previous one; this is the structure described in Blockchain.[2]
  • Merkle trees. To let old blocks be compacted without breaking a block's hash, the paper hashes transactions in a Merkle tree and includes only its root in the block's hash.[2]

The paper also describes ownership as a chain of digital signatures, each made over a hash of the previous transaction and the next owner's public key.[2] See Bitcoin for the wider system.

Sources

  1. Secure Hash Standard (SHS), FIPS PUB 180-4, National Institute of Standards and Technology, August 2015.
  2. Bitcoin: A Peer-to-Peer Electronic Cash System, Satoshi Nakamoto, bitcoin.org.
  3. Hash Functions, NIST Computer Security Resource Center, page updated 16 September 2026.
  4. SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions, FIPS 202, NIST, August 2015.
  5. The first collision for full SHA-1 (SHAttered), CWI Amsterdam and Google, 23 February 2017.
  6. "Hash function" and "Collision resistance", NIST Computer Security Resource Center glossary, accessed 3 December 2026.