Hashing

Hashing is the process of converting data into a fixed-length string using cryptographic algorithms, helping secure and verify blockchain information.

hashing glossary banner image

What is Hashing?

Hashing has appeared in nearly every article in this series so far; it was the foundation of our very first explanation of what a BlockchainBlockchainThink of blockchain as a public notebook that everyone owns a copy of. Whatever gets written in it is permanent and visible to all.Keep learning actually is, it underpins Proof of WorkProof of WorkProof of Work (PoW) is a consensus mechanism where miners use computing power to validate transactions and secure the blockchain.Keep learning Crypto MiningCrypto MiningCrypto mining is the process of using computing power to validate blockchain transactions and earn cryptocurrency rewards.Keep learning, it secures Crypto WalletsCrypto WalletsA crypto wallet doesn’t store coins like a piggy bank. Instead, it keeps keys that let you access your crypto on the blockchain.Keep learning addresses, and it even forms the backbone of Proof of History's sequential time-ordering. Given how much weight this single concept carries across the entire technology stack, it's earned a dedicated, closer look of its own: what actually makes a hash function suitable for this kind of work, the specific properties that matter, and a few applications we haven't yet had the chance to explore in detail.

A Quick Recap

As covered in our first article, a hash function takes any input; of any size; and produces a fixed-length output, called a hash or digest. The same input always produces the same output, and even a tiny change to the input produces a completely different, unpredictable result. BitcoinBitcoinBitcoin is a decentralized digital currency that enables secure peer-to-peer transactions without relying on a central authority.Keep learning and Bitcoin-derived systems rely on SHA-256; EthereumEthereumEthereum is a decentralized blockchain platform that runs smart contracts and dApps, using its native cryptocurrency (ETH) for transactions and fees.Keep learning primarily uses a closely related variant called Keccak-256.

This article goes a level deeper than that initial overview, focusing specifically on why these properties hold, and where else in the blockchain stack hashing quietly does its work.

The Four Properties That Actually Matter

Not just any function that scrambles data qualifies as a CryptographyCryptographyCryptography is the science of securing information using mathematical techniques to protect data, ensure privacy, and verify authenticity.Keep learning hash function suitable for blockchain use. A genuinely secure cryptographic hash function needs to reliably satisfy four specific properties.

1. Determinism

The same input must always, without exception, produce the same output. This sounds obvious, but it's foundational: if hashing the same transaction data twice produced two different results, Blockchain NodesBlockchain NodesA node is simply a computer that participates in a blockchain network. Each node stores a copy of the blockchain and helps verify transactions.Keep learning would have no reliable way to verify each other's work, and the entire Blockchain consensus mechanismsBlockchain consensus mechanismsA consensus mechanism is a method for validating transactions and securing a blockchain without relying on a central authority.Keep learning explored throughout this series would collapse immediately.

2. Preimage Resistance

Given a hash output, it should be computationally infeasible to work backward and determine what input produced it. This is the one-way property discussed in our first article; and it's the property that lets a hash function stand in securely for the original data, without ever exposing that original data itself.

3. The Avalanche Effect (Second Preimage Resistance)

A tiny change to the input; flipping a single bit, changing one character, adjusting a timestamp by a fraction of a second; should produce a dramatically different, entirely unpredictable output. This is often called the avalanche effect, and it's what makes tampering immediately detectable: there's no way to make a small, "stealthy" edit to a piece of hashed data that results in only a small, easy-to-miss change in its hash.

You can observe this directly using the same hash calculator tools referenced in our first article; try hashing "Hello" and then "hello" (just changing the capitalization of one letter) using Xorbin's SHA-256 Calculator, and compare the two results side by side. The two outputs share no discernible resemblance to one another, despite the inputs differing by only a single character.

4. Collision Resistance

It should be computationally infeasible to find two different inputs that produce the same hash output; an event known as a collision. Because a hash function maps an effectively infinite range of possible inputs onto a fixed-length output, collisions are technically guaranteed to exist somewhere in the mathematical sense (this is a basic consequence of the pigeonhole principle). What matters in practice isn't that collisions are impossible, but that they're so astronomically improbable to find; even deliberately, with significant computing power thrown at the problem; that they pose no realistic threat. SHA-256, specifically, has no known practical collision attack as of this writing, which is a large part of why it remains trusted for this kind of work over a decade after Bitcoin's launch.

It's worth noting that not every widely used hash function has aged this well. MD5 and SHA-1, both once considered secure and widely deployed across the broader software industry, have since had practical collisions demonstrated by researchers, and are now considered unsuitable for any security-critical application. This history is itself instructive: it's part of why Bitcoin's choice of SHA-256, and Ethereum's choice of Keccak-256, weren't arbitrary; both were already well-studied, heavily scrutinized algorithms with strong, long-standing reputations for collision resistance at the time each Blockchain NetworkBlockchain NetworkA blockchain network is a system of computers connected to each other that follow the same set of rules to record, share, and validate transactions.Keep learning was designed.

Merkle Trees: Hashing Many Things at Once, Efficiently

One application of hashing we haven't yet covered in this series, despite its central importance, is the Merkle tree; and it's worth understanding, since it's how a block efficiently summarizes potentially thousands of individual transactions into a single, compact hash.

Here's the problem a Merkle tree solves: a single Bitcoin block can contain thousands of individual transactions. Hashing all of that data as one enormous, undivided blob would work in principle, but it would be inefficient to verify; to confirm that even a single transaction within that block hadn't been altered, you'd need to re-hash and check the entire block's contents all over again.

A Merkle tree solves this through a layered structure:

  1. Each individual transaction is hashed on its own
  2. Those hashes are paired up and hashed together, producing a new, smaller set of hashes
  3. This pairing-and-hashing process repeats, layer by layer, each level containing half as many hashes as the one below it
  4. The process continues until a single hash remains at the very top; the Merkle root

This Merkle root is the only piece of transaction data actually stored directly in a block's header (the small summary record that gets hashed during mining, as described in our Proof of Work article). And yet, because of how the tree was constructed, that single hash effectively, verifiably represents every transaction beneath it. If even one transaction, anywhere in the entire set, were altered, that change would cascade upward through the tree; thanks to the avalanche effect discussed above; and produce a completely different Merkle root.

This structure also enables something called a Merkle proof: a way to verify that a single specific transaction is included in a block, using only a small handful of hashes from the tree, rather than needing to download and check every transaction in the entire block. This is, not coincidentally, exactly how the light nodes discussed in our blockchain nodes article are able to verify transactions of interest without storing the full blockchain themselves.

For a genuinely excellent, hands-on visualization of this entire process, the Merkle Tree section of Anders Brownworth's Blockchain Demo; the same tool referenced in our earlier articles for visualizing hashing and block-chaining; lets you add and edit individual transactions and watch, in real time, how the Merkle root above them changes and how that change would be detected.

Hashing in Mining, Revisited

Our Proof of Work article covered mining in the context of competing for the right to add the next block. It's worth briefly reconnecting that process to the more general hashing properties discussed here: mining is, at its core, simply a deliberate, brute-force exploitation of the avalanche effect. Because there's no way to predict what a SHA-256 output will look like in advance, and no way to work backward from a desired output to find a matching input, the only available strategy is exhaustive trial and error; changing the nonce, re-hashing, checking the result, and repeating, potentially trillions of times, until a qualifying hash happens to be found. This is precisely why preimage resistance is what makes Proof of Work expensive and meaningful in the first place; if it were possible to predict or reverse-engineer a qualifying hash, the entire security model would collapse.

Hashing Beyond Bitcoin and Ethereum

It's worth noting that hashing's usefulness inside blockchain technology extends well beyond transaction verification and mining. A few additional applications worth knowing about:

  • Smart contract verification. As referenced in our blockchain protocol article, the code governing Smart ContractsSmart ContractsA smart contract is a self-executing computer program deployed on a blockchain. It contains rules and conditions written directly into code.Keep learning is itself hashed, allowing anyone to verify that the contract deployed on-chain genuinely matches a specific, publicly reviewed version of its source code.
  • Non-fungible tokens (NFTsNFTsAn NFT is a unique digital asset stored on a blockchain that proves ownership of something.Keep learning). The metadata and underlying digital files associated with an NFT are commonly hashed and stored (or referenced) on-chain, providing a tamper-evident link between the Crypto TokensCrypto TokensCrypto tokens are digital assets built on existing blockchains that represent value, access, or utility within a specific project or ecosystem.Keep learning and the specific digital asset it represents.
  • Password and credential storage, far beyond blockchain specifically. This is a more general application worth knowing, since it's a direct, everyday illustration of preimage resistance in action: responsible services never store your actual password, only its hash, meaning that even if their database were ever breached, your original password couldn't practically be recovered from the stolen data.

Choosing a Hash Algorithm: It's Not One-Size-Fits-All

Different blockchain networks have made different choices here, and it's worth understanding why, briefly. Bitcoin's SHA-256, as discussed, was chosen for its proven track record and its specific suitability for the kind of repeated, brute-force hashing Proof of Work requires. Ethereum's Keccak-256 (closely related to, though technically distinct from, the standardized SHA-3 algorithm) was selected during Ethereum's design phase for broadly similar reasons, with some differences in internal structure and performance characteristics. Other networks have made other choices entirely; Litecoin, for instance, uses an algorithm called Scrypt, specifically chosen to be more resistant to the kind of specialized ASIC hardware described in our Proof of Work article, in an attempt (only partially successful, over time) to keep mining more accessible to ordinary consumer hardware.

If you're curious to compare these algorithms directly, SeedTool.io's Hash Generator lets you input the same piece of text and instantly view its output under several different hashing algorithms side by side; SHA-256, SHA-1, MD5, and Keccak-256 among them; making the practical differences between them, including output length and general appearance, easy to compare directly.

Bringing It Together

Hashing is, in many ways, the single concept that makes the rest of this series possible; a deceptively simple idea (turn any input into a fixed-length, unpredictable, tamper-evident fingerprint) that turns out to be powerful enough to underpin an entire decentralized financial system. To summarize:

  • A secure cryptographic hash function must be deterministic, preimage-resistant, exhibit the avalanche effect, and be collision-resistant
  • Merkle trees let an entire block's worth of transactions be summarized into a single hash, the Merkle root, while still allowing efficient, partial verification through Merkle proofs
  • Mining, covered in depth in our Proof of Work article, is fundamentally a brute-force exploitation of preimage resistance; there's no shortcut to finding a qualifying hash other than trying, and re-trying, at enormous scale
  • Hashing's applications extend well beyond transactions; into smart contract verification, NFT metadata, and even everyday password security outside of blockchain entirely
  • Different networks choose different hash algorithms (SHA-256, Keccak-256, Scrypt, and others) based on differing priorities around security, performance, and hardware accessibility

Combined with the rest of this series, hashing now sits in its proper place: not just the mechanism behind a single block's fingerprint, as introduced in our first article, but the broader cryptographic workhorse running quietly underneath nearly every other concept this series has examined; from the smallest transaction to the largest network-wide consensus mechanism.

Recap

Hashing turns any data into a fixed-length digital fingerprint that can’t be reversed or subtly altered. Its properties make blockchain data secure, verifiable, and tamper-resistant.

Tag System

The tags found in our glossary are there to help you better understand presented definitions. They showcase how certain concepts integrate and interact within the ecosystem.

Rectangular tags signal a concept related to BlockchainBlockchainThink of blockchain as a public notebook that everyone owns a copy of. Whatever gets written in it is permanent and visible to all.Keep learning as a technology. Whereas rounded tags represent CryptocurrencyCryptocurrencyCryptocurrency, often called “crypto,” is a form of digital currency that uses cryptography (advanced math and code) to keep it secure.Keep learning in more of a financial aspect. You’ll also see rectangular dashed tags for Web3Web3Web3 is the idea of a decentralized internet powered by blockchain.Keep learning and  rounded dashed tags for DeFiDeFiDeFi stands for Decentralized Finance. It refers to a collection of applications and platforms built on blockchain that allow people to transact without banks.Keep learning specifically.

Learn more about the relationship between all the tags and their respective concept with our Free Interactive Courses.

FAQ

No. Encryption is reversible with a key, while hashing is intentionally one-way and irreversible.

Fixed length makes hashes easy to compare, store, and verify consistently across networks.

In theory yes, but good hash functions make this so unlikely that it’s practically impossible.

The network would need to upgrade to a stronger algorithm to maintain security and trust.

It’s used in password storage, file verification, data integrity checks, and cybersecurity.

Partially. It hides raw data, but patterns or reused inputs can still reveal information.

Extremely fast for verification, but intentionally costly in proof-of-work systems to prevent abuse.

Because anyone can independently verify data without trusting a central authority.

More Blockchain fundamentals

oracles glossary cover image

Oracles

A crypto oracle is a service that feeds external real-world data into blockchains so smart contracts can react to off-chain events.

Keep learning
blockchain glossary cover image

Blockchain

Think of blockchain as a public notebook that everyone owns a copy of. Whatever gets written in it is permanent and visible to all.

Keep learning