π Hashing Hashing
Hashing runs any input β a word, a file, a transaction, even a whole block β through a fixed math function that spits out a short, fixed-length string called a hash. The same input always produces the same hash, but you can never run it backward to recover the original.
πͺͺ The simple version β a digital fingerprint
Think of a hash as a digital fingerprint for a piece of data. Feed in anything and the function returns a unique-looking string that identifies it. Two useful things follow from this. First, it's deterministic: the same input always gives the exact same hash, so anyone can re-check it. Second, it's a tamper-evident seal: if even one character of the data changes, the fingerprint no longer matches, so any meddling shows up instantly.
π§ͺ The four properties that make it useful
| Property | What it means |
|---|---|
| π Deterministic | The same input always produces the exact same hash |
| β‘οΈ One-way | You can go input β hash, but never hash β input |
| π Avalanche effect | Change one character and the whole hash looks totally different |
| π₯ Collision resistance | It's practically impossible to find two inputs with the same hash |
π The output is always a fixed length. SHA-256 returns a 256-bit hash β written as 64 characters β whether you hash a single letter or an entire movie.
π Why crypto leans on hashing
A blockchain is a chain of blocks, and hashing is the glue. Each block stores the hash of the block before it. Tamper with an old block and its hash changes, which breaks the link to every block that follows β so the fraud is obvious to the whole network. Hashing also creates the strings you actually see on a block explorer: transaction IDs, block hashes, and wallet addresses are all hash-derived.
βοΈ Where you'll meet it: Bitcoin and Ethereum
Bitcoin uses a function called SHA-256 for mining (Proof of Work), for verifying transactions, and for generating addresses. Ethereum uses a different one called Keccak-256. The names differ, but the job is the same: produce a fixed-length fingerprint that no one can fake or reverse.
π¨ Things beginners get wrong
- π "A hash can be decrypted" β It can't. There's no key and no reverse path; the only way to match a hash is to hash the original input again
- π° "Hashing equals encryption" β Different jobs. Encryption hides data so it can be unlocked later; hashing fingerprints data so changes get caught
- π "A bigger file makes a bigger hash" β No. The output length is fixed by the function, not by the input size
β FAQ
- Is hashing the same as encryption?
- No. Encryption is reversible: with the right key, an encrypted message can be turned back into the original to protect confidentiality. Hashing has no key and no undo button β it is one-way, used to verify that data hasn't changed and to create identifiers.
- Can you decrypt or reverse a hash to get the original input?
- No. A hash is one-way. You can compute the hash from an input, but you cannot work backward from the hash to recover what was put in. The only way to match a hash is to already have the original input and hash it again.
- Why does every hash look the same length?
- The function always outputs a fixed length, no matter how big the input is. SHA-256, the function Bitcoin uses, always produces a 256-bit hash written as 64 characters β whether you hash one letter or a whole movie file.