DEV Community

Sreekar Reddy
Sreekar Reddy

Posted on • Originally published at sreekarreddy.com

πŸ”’ Hashing Explained Like You're 5

A fingerprint for data

Day 19 of 149

πŸ‘‰ Full deep-dive with code examples


The Fingerprint Analogy

Every person has a unique fingerprint.

From a fingerprint, you CAN:

  • βœ… Identify who someone is
  • βœ… Check if two prints match

From a fingerprint, you CANNOT:

  • ❌ Recreate the whole person!

Hashing creates a "fingerprint" for data.


How It Works

Put any data into a hash function:

"hello" β†’ a591a6d40bf420404a011733cfb7b190
"Hello" β†’ 8b1a9953c4611296a827abf8c47804d7
"hello " β†’ (completely different!)
Enter fullscreen mode Exit fullscreen mode

Notice:

  • Same input β†’ Same output (for the same hash function)
  • Tiny change β†’ Completely different output
  • Can't reverse it!

Why Can't You Reverse It?

Hashing throws away information.

Imagine making a smoothie:

  • Apple + Banana + Milk β†’ Smoothie

Can you separate the smoothie back into apple, banana, and milk?
No! The blending is one-way.

Hashing is the same. Data goes in, hash comes out, no going back.


Real Uses

Password Storage:

Password: "pizza123"
Stored: "5d41402abc4b2a..."

You type "pizza123" β†’ Hashed β†’ Matches stored hash? βœ… Login!
Enter fullscreen mode Exit fullscreen mode

Good websites store a hash of your password (not the password itself).

File Integrity:
Download says: Hash should be abc123...
Your file's hash: abc123... β†’ βœ… File wasn't tampered with!


In One Sentence

Hashing turns data into a fingerprint-like value that can help verify matches but can't be reversed.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

Top comments (0)