Skip to content
Minute Campus.

Everyday computer scienceLesson 021 min

How does a website check your password without storing it?

A well-built website never saves your password. It runs the password through a hash function, a one-way scramble that gives the same result each time and cannot be run backwards. The site stores only the scramble and compares it at login. A random salt makes two identical passwords differ, and the function is slow on purpose, so mass guessing takes too long.

Remember

A good site can reset your password but can never tell you the old one.

Transcript

The lesson, word for word.

Read it at your own pace, or search the page for a term.

How can a website check your password without keeping it? A well-built site never saves the password itself. It runs it through a hash function. Think of a one-way blender. Put a password in, and out comes a long scramble of letters and numbers. The same password always gives the same scramble. But there is no way to run the blender backwards. The site saves only the scramble. When you log in, it blends what you typed and compares the two. If they match, you are in. So if thieves steal the database, they get scrambles, not passwords. Two extras make it stronger. A random value called a salt is mixed in, so two people with the same password get different scrambles. And the blender is made slow on purpose, so guessing millions of passwords takes far too long. It is also why a good site can reset your password, but can never tell you the old one.

Questions? Comment on the lesson on YouTube

New lessons every day.

Follow Minute Campus where you already scroll.