Serksa
All Concepts
Security

Password Hashing

1

What is it?

<strong>Password hashing</strong> is the process of converting passwords into irreversible scrambled strings before storing them. Even if your database is stolen, attackers can't read the original passwords.

2

Think of it like...

The Meat Grinder Analogy

Hashing is like grinding meatβ€”you can turn steak into ground beef, but you can't turn ground beef back into steak. Same with passwords: you can hash them but can't unhash them.

πŸ₯©

Password (Meat)

Original form

βš™οΈ

Hash Function (Grinder)

One-way process

πŸ”

Hash (Ground Meat)

Can't reverse

3

Visual Flow

πŸ”‘Password

User Input

β†’
πŸ”Hash Function

bcrypt/Argon2

β†’
πŸ’ΎHashed Password

Stored in DB

4

Where you see it

1

User creates password

password123 (never store this!)

2

Hash with salt

bcrypt.hash('password123', 10)

3

Store hash in database

$2b$10$N9qo8uLOickgx2ZMRZoMye...

4

User logs in

They enter password123 again

5

Compare hashes

bcrypt.compare(input, storedHash) β†’ true/false

5

Common Mistake

❌

Wrong

"Encryption and hashing are the same"

βœ…

Correct

<strong>Encryption is reversible, hashing is not</strong>. Encryption: lock with key (can unlock). Hashing: one-way transformation (can't reverse). Always hash passwords, never encrypt.

πŸ’‘ Real-World Example

Why hashing matters:

1

Database gets hacked and leaked

2

Attackers see: $2b$10$N9qo8uLOickgx2ZMRZoMye...

3

Can't reverse the hash to get original password

4

Users' passwords remain safe (if strong hash like bcrypt)