# Password Hashing

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

**Field:** Software Development  
**Category:** Auth  
**Also known as:** Hashed Password, bcrypt, Argon2, Password Salt

## 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.

## 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

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

## 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.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Authentication](https://learn.benibix.com/term/development/authentication)
- [Hashing (Cryptography)](https://learn.benibix.com/term/development/hashing)
- [Database](https://learn.benibix.com/term/development/database)
- [Encryption](https://learn.benibix.com/term/development/encryption)

---

Source: https://learn.benibix.com/term/development/password-hashing
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
