Skip to content

GLOSSARY · BLOCKCHAIN & WEB3

Hash

A cryptographic function that transforms data of any size into a fixed string of characters, unique for each entry.

Reviewed on

What is a hash?

A hash is the result of applying a cryptographic hash function to some data: a fixed-length string (256 bits for SHA-256) that works as a fingerprint of that data. The same input always gives the same hash; any change to the input gives, with very high probability, a different hash; and the input cannot be rebuilt from the hash. That is why hashes are used to check that something has not changed, to chain the blocks of a blockchain and to identify transactions.

What is a hash and how does it work?

A hash function works on bit strings and returns an output of fixed length (NIST glossary, FIPS 186-5). The functions in NIST's FIPS 180-4 standard are called secure because it is computationally infeasible to find a message that corresponds to a given hash, or to find two different messages with the same hash (a collision). The same standard adds that any change to a message will, with very high probability, result in a different hash.

SHA-256 example. The hash of "abc" is ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad. Change the last letter to "abd" and you get a52d159f262b2c6ddb724a61840befc36eb30c88877a4030b65cbe86298449c9: they look nothing alike. Both are 64 hexadecimal characters, that is, 256 bits.

What is SHA-256?

SHA-256 is one of the hash functions defined in NIST's FIPS 180-4 standard (August 2015), alongside SHA-1, SHA-224, SHA-384, SHA-512, SHA-512/224 and SHA-512/256; NIST groups all of them except SHA-1 in the SHA-2 family. SHA-256 accepts messages shorter than 264 bits, processes them in 512-bit blocks with 32-bit words and returns a 256-bit digest. It is the function Bitcoin uses.

Types of hash: MD5, SHA-1, SHA-256 and Keccak-256

AlgorithmHash sizeWhere it is definedStatus and use
MD5128 bitsRFC 1321 (April 1992)No longer acceptable where collision resistance is required, such as digital signatures (RFC 6151, March 2011)
SHA-1160 bitsFIPS 180-4 (NIST)Collision attacks have been used against it; on December 15, 2022 NIST announced it should be phased out by December 31, 2030
SHA-256256 bitsFIPS 180-4 (NIST)SHA-2 family, recommended by NIST. Bitcoin applies it twice (double SHA-256) to block headers and transactions
SHA3-256256 bitsFIPS 202 (NIST, August 2015)SHA-3 family, recommended by NIST; based on Keccak, the winner of the SHA-3 competition
Keccak-256256 bitsThe Keccak submission to the SHA-3 competition (Bertoni et al.)Ethereum's hash function (KEC in the Yellow Paper). It does not give the same result as SHA3-256, because FIPS 202 appends a two-bit suffix (01) to the message before applying Keccak

Hashing vs. encryption

HashEncryption
Does it use a key?NoYes: it turns plaintext into ciphertext with an algorithm and a key
Is it reversible?No: it is one-wayYes: with the right key it is decrypted
Length of the resultFixedDepends on the size of the data
What it is forChecking integrity and identifying dataKeeping data secret

The definitions of encryption come from the NIST glossary (SP 800-57 and SP 800-12). A digital signature builds on hashing: the message is hashed and the hash is signed with a private key, so any change to the message makes verification fail (FIPS 180-4).

SHA-256 in Bitcoin

Each Bitcoin block header is 80 bytes long and contains the double SHA-256 hash of the previous header, which is what chains the blocks together, and the root of a Merkle tree built from the identifiers of all its transactions. For the block to be valid, its header hash must be equal to or below a threshold (the target). Miners change the header's nonce until they find a hash that meets it: that is proof of work.

What is a transaction hash (txid)?

It is a transaction's identifier. In Bitcoin, the TXID is the double SHA-256 of the serialized transaction (Bitcoin developer documentation). On Ethereum, every transaction also has a hash that identifies it, and it is the code you look up in a block explorer to see whether it has been confirmed. Ethereum also uses Keccak-256 for addresses: an address is the rightmost 160 bits of the Keccak-256 hash of the public key (Yellow Paper).

Uses of hashing off-chain

Storing a document's hash on a blockchain lets you prove later that the document existed on that date and has not changed, without publishing its content: you just recompute the hash and compare. This is the basis of traceability and document certification systems.

Official sources: NIST FIPS 180-4, Secure Hash Standard; NIST FIPS 202, SHA-3 Standard; NIST retires SHA-1, December 15, 2022; RFC 1321, MD5; RFC 6151, MD5 security considerations; NIST glossary: encryption; Bitcoin: block chain reference; Ethereum Yellow Paper.

Framework verified as of October 15, 2026. At Unknown Gravity we use hashes in smart contracts, traceability records and document certification, and we review how they are used in our smart contract audits. Talk to us.

Learn more: What Is Blockchain and How Does It Work? Types, Real Examples and Limits

Explained simply

A hash is like a fingerprint for data: a fixed-length code that changes completely if you change even one letter. It is not used to get the data back, but to check that nobody has touched it. On a blockchain it chains the blocks together and identifies every transaction.

Hash: key points

  • It condenses data into a fixed-length string (256 bits for SHA-256)
  • It is one-way: the input cannot be recovered from the hash
  • NIST defines SHA-256 in FIPS 180-4; Bitcoin applies it twice
  • Ethereum uses Keccak-256, which does not match SHA3-256
  • MD5 is not collision resistant (RFC 6151) and NIST is phasing out SHA-1 by December 31, 2030

Hash: advantages

  • Integrity: any change to the data gives a different hash
  • Fixed size: a whole document's hash takes up 64 hexadecimal characters with SHA-256
  • Proof without disclosure: publishing a document's hash does not publish its content

Hash: disadvantages

  • It does not encrypt: it does not hide data; that takes encryption
  • Algorithms age: MD5 and SHA-1 no longer work where collisions matter
  • Guessable inputs: if the data is short or predictable, it can be found by trying candidates