Skip to content
BENIBIX Learn

Password Hashing

Development🔑 AuthAuthentication

Also known as Hashed Password, bcrypt, Argon2, Password Salt

Keeping a scrambled copy of a password. It can never be turned back.

Think of it like

Think of it like a blender. A banana goes in and a smoothie comes out. You cannot get the banana back.

Example

Lucy's app stores her password as a 60-character bcrypt string. When the database leaks, the thieves get the strings, not her password.

Why it matters

Databases leak. Hashing means a leak does not hand out every user's password.

Definition

Password hashing turns a password into a scrambled string that cannot be turned back. The app stores only that string, never the real password. When you log in, it hashes what you typed and compares the two strings. A random value called a salt is mixed in, so two people with the same password get different hashes. Slow methods like bcrypt and Argon2 are used so guessing takes years.

Example code

python
bcrypt.hashpw(b"hunter2", bcrypt.gensalt())
# b'$2b$12$RPynI795imQFtnz12B/.6uNyCR5P4ROQy.G9Lkn4FAAtddXaa4eDy'
One password in, a salted bcrypt hash out. The 12 sets how slow it is.

Common mistake

Using a fast hash like SHA-256 for passwords. Fast hashes let a thief try billions of guesses a second.

Key takeaways

  1. 1
    One way only. It cannot be undone.
  2. 2
    Salted. Same password, different hash.
  3. 3
    Slow on purpose. bcrypt or Argon2.