Skip to content

What is a hash? SHA-256 and why blockchains depend on hashing

What a cryptographic hash is, what makes SHA-256 secure, how bitcoin uses hashing for mining and linking blocks, Ethereum's Keccak-256, and what hashing isn't.

Figures checked against 4 official and primary sources on . See the sources · How we check

Key points

  • A hash function turns any data into a short, fixed-size fingerprint. SHA-256, defined by the US standards body NIST, always produces 256 bits.
  • NIST says it's computationally infeasible to find data that matches a given hash, or two different pieces of data with the same hash, and that any change to the data will very probably change the hash.
  • Bitcoin uses hashing to link blocks together and for proof of work: miners search for a block whose hash meets a target.
  • Ethereum derives account addresses from a Keccak-256 hash of the public key. A hash is a fingerprint, not encryption: it can't be reversed to get the data back.
In this guide
  1. A fingerprint for data
  2. A hash in action
  3. The three properties that matter
  4. How bitcoin uses hashing
  5. How Ethereum uses hashing
  6. What hashing isn’t
  7. Key terms
  8. Where you’ll see hashes
  9. Hashing and quantum computers

Almost every explanation of crypto mentions hashes: block hashes, transaction hashes, hashing power. They’re one of the basic building blocks of blockchains, and the idea behind them is simpler than it sounds.

This guide explains what a hash is, the properties that make it useful for security, and how bitcoin and Ethereum use it. For the bigger picture, see what is a blockchain?

A fingerprint for data

A hash function takes data of any size, a word, a file, a whole block of transactions, and produces a short output of fixed size, called a hash or message digest.

The US National Institute of Standards and Technology (NIST) sets out the best-known family of these functions in FIPS 180-4, the Secure Hash Standard. It says the algorithms can be used to generate digests of messages, and that the digests are used to detect whether a message has changed since the digest was created.

The standard covers several algorithms, including SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512. For SHA-256, the one bitcoin is best known for, the final result is always a 256-bit digest, usually written as 64 hexadecimal characters, whatever the size of the input.

A hash in action

Here’s what SHA-256 produces for three almost identical inputs:

Input SHA-256 hash
hello 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Hello 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
hello. 1589999b0ca6ef8814283026a9f166d51c70a910671c3d44049755f07f2eb910

Three things stand out. Each hash is the same length, 64 characters. A capital letter or a period changes the result completely. And the same input always gives the same hash, so anyone can check it for themselves with any SHA-256 tool.

The three properties that matter

NIST explains why these algorithms are called secure: for a given algorithm, it is computationally infeasible

  1. to find a message that corresponds to a given digest; or
  2. to find two different messages that produce the same digest.

It adds that any change to a message will, with a very high probability, result in a different digest.

In plain terms:

  • One-way: you can’t work backwards from a hash to the data.
  • No useful clashes: you can’t find two different inputs with the same hash.
  • Sensitive: change one character and the hash looks completely different.

These properties are what let a short hash stand in for a large amount of data. If two copies of a file have the same SHA-256 hash, you can be confident they’re identical.

How bitcoin uses hashing

Linking blocks. The bitcoin white paper describes a chain of blocks in which each block includes the hash of the previous block. Change anything in an old block and its hash changes, which breaks the link to every block after it. That’s what makes the history hard to rewrite. See the bitcoin white paper explained.

Proof of work. The white paper explains that miners repeatedly change a number in the block, called a nonce, until the block’s hash, for example with SHA-256, starts with enough zero bits. Because a hash can’t be predicted, the only way to find one is to try again and again. The total rate of these attempts is what people mean by hashing power or hash rate. See bitcoin mining explained.

Summarizing transactions. The white paper also describes hashing a block’s transactions into a Merkle tree, so the block header only needs to carry one hash for all of them. That’s what lets lightweight wallets check that a transaction is in a block without downloading everything. See what is a blockchain node?

How Ethereum uses hashing

Ethereum uses a different hash function, Keccak-256. ethereum.org explains that your public address is the last 20 bytes of the Keccak-256 hash of your public key, with 0x added at the start, giving a 42-character address.

Hashes appear in Ethereum accounts too. ethereum.org describes a codeHash, the hash of a smart contract’s code, and a storageRoot, a 256-bit hash of the root of the data structure that holds an account’s storage. See public and private keys explained.

What hashing isn’t

It isn’t encryption. Encryption is meant to be reversed by someone with the key. A hash is one-way: it proves that data matches, without revealing or storing the data.

It isn’t a guarantee of legitimacy. A transaction hash proves a particular transaction exists on the blockchain, not that the person who asked you to send it was honest. See how to use a block explorer.

It isn’t the same as your private key. Your keys are what control your crypto. Hashes are used throughout the system, but knowing a hash doesn’t give anyone access to your funds.

Key terms

  • Hash, digest, fingerprint: the fixed-size output of a hash function.
  • SHA-256: the 256-bit member of NIST’s Secure Hash Standard, used by bitcoin.
  • Keccak-256: the hash function Ethereum uses for addresses and much of its data.
  • Nonce: the number miners change to get a different block hash.
  • Merkle root: a single hash that summarizes all the transactions in a block.

Where you’ll see hashes

  • Transaction IDs on a block explorer are hashes of the transaction.
  • Block hashes identify each block.
  • Hash rate figures describe how much hashing work bitcoin miners are doing.
  • Software downloads often publish a SHA-256 hash, so you can check that the file you downloaded hasn’t been tampered with.

Hashing and quantum computers

You may read that quantum computers threaten crypto. NIST says hash functions such as SHA-256 are significantly less vulnerable to known quantum attacks than the digital signatures that protect wallets, so the main concern is signatures. See quantum computing and crypto for what they say.

Frequently asked questions

Can you reverse a hash to get the original data?
Not in practice. NIST describes the SHA hash algorithms as secure because it's computationally infeasible to find a message that corresponds to a given message digest. That's why a hash works as a fingerprint, not as a way to store data.
Is hashing the same as encryption?
No. Encryption is designed to be reversed by someone with the right key. A hash is designed to be one-way: you can check that data matches a hash, but not recover the data from it.
How long is a SHA-256 hash?
256 bits, usually written as 64 hexadecimal characters. NIST's standard says the final result of SHA-256 is a 256-bit message digest.
Why do miners compute so many hashes?
Because they can't predict the result. Proof of work, as the bitcoin white paper describes it, means trying different values in a block until its hash meets the target. The only way to find one is to keep trying.
Could quantum computers break SHA-256?
NIST says hash functions such as SHA-256 are significantly less vulnerable to known quantum attacks than public-key algorithms. The main concern is the signatures that protect wallets. See our guide to quantum computing and crypto.

Sources

  1. FIPS 180-4: Secure Hash Standard (SHS), August 2015 — National Institute of Standards and Technology
  2. Bitcoin: A Peer-to-Peer Electronic Cash System (white paper) — Bitcoin.org
  3. Ethereum accounts — ethereum.org
  4. NIST IR 8547 (Initial Public Draft): Transition to Post-Quantum Cryptography Standards (November 2024) — National Institute of Standards and Technology

First published . Spotted an error or an outdated figure? Tell us and we will check it against the source.