How Does Passwords & hash functions (Simply Explained) Work?

A password is like a secret key that lets you into a special place, and a hash function is like a clever locker that changes your key into something new so no one can see it.

Imagine you want to get into the cookie jar. Instead of telling everyone your real password, say, "cookie123", you use a hash function, which acts like a magical machine (but not too magical). It takes your password and turns it into something else, like "7x9z4". This new thing is called a hash. Now, even if someone sees the hash, they can't figure out what your original password was.

How the Locker Works

When you try to get into the cookie jar again, you give the same password to the locker machine. It does the same trick, turns "cookie123" into "7x9z4". If the new hash matches the one it already has, it lets you in!

This way, even if someone sneaks a look at the hash, they don’t know your real password, just like how you can't tell what flavor of ice cream is inside a wrapped cone.

Take the quiz →

Examples

  1. A user types in their password, and a hash function turns it into a unique code that’s stored instead of the actual password.
  2. Imagine turning your name into a secret code that only you can create, that's what a hash function does for passwords.
  3. When you log in, the system checks if the hash of your typed password matches the one stored on file.

Ask a question

See also

Discussion

Recent activity