How Does Password Hashing, Salts Work?

A password is like a secret code that lets you get into your favorite app or game, and hashing and salting are ways to keep that code safe.

Imagine you have a special box where you put your password, and then it turns into a jumbled mess. That's hashing, the box scrambles your password so no one can read it easily. But if two people use the same password, their scrambled versions would look the same. That’s not good.

So we add something extra to each password before scrambling it, like adding a pinch of salt to your cookies. This is called salting. The salt is different for every person, so even if two people have the same password, their scrambled versions will look completely different.

How It Works in Real Life

Think of hashing and salting as your backpack’s lock. Every time you put your lunch in your backpack, it goes through a special locker that makes it hard to steal (that's the hashing). But if everyone uses the same locker, thieves might guess what's inside. So you add a unique sticker to each backpack, that's the salt.

Now even if two people have the same lunch, their lockers will look different when they go through the special locker. Thieves won’t know what’s inside, and your snacks stay safe!

Take the quiz →

Examples

  1. A website stores your password as a scrambled version, not the real one.
  2. Adding a random string to your password before scrambling makes it harder to guess.
  3. Even if someone steals the scrambled passwords, they can’t easily figure out the original ones.

Ask a question

See also

Discussion

Recent activity