Course / Foundations / Lesson 3

Hashing: a fingerprint for data

Change one capital letter and the entire fingerprint changes. Try it yourself below - this is the math that makes tampering obvious.

23:04 to 26:11 - Week 2 with Dr Neetu Sharma About the series

What's going on

A hash function takes any input - a word, a whole book, a transaction - and produces a fixed-length string of characters. Neetu calls it a fingerprint: unique to the input, and always the same length no matter how big the input is.

Here's the property that makes it powerful. Hash the word "Hello" and you get one string. Change a single letter to "hello" and the entire output is completely, unrecognizably different. A tiny change in, a drastic change out. There's no "close" - it either matches exactly or it doesn't.

Blockchains use SHA-256, which turns anything into a 256-bit fingerprint. Because the smallest edit changes the whole fingerprint, you can't secretly alter a record without everyone noticing the fingerprint no longer matches. The activity below runs real SHA-256 in your browser - change one character and watch.

Real-world impact

This is why a blockchain can't be edited in secret. Tamper with one old transaction and its fingerprint changes, which breaks the next block's reference to it, which breaks the next - the whole chain lights up wrong. You'll see exactly this in the next lesson.

Key terms

Hash function
Turns any input into a fixed-length fingerprint. Same input always gives the same output.
SHA-256
The specific hash function Bitcoin uses; its output is 256 bits (64 hex characters).
Avalanche effect
A one-character change in the input completely scrambles the output.