Why a hash is one-way, and why that is exactly what a password needs.
Hashing vs Encryption
In brief
Objectives
- Explain why a hash cannot be reversed
- Justify hashing passwords instead of encrypting them
A hash is a one-way fingerprint of data. Unlike encryption, there is no key and no way back — you cannot un-hash a value to recover the original.
That one-way property is exactly why passwords are hashed, not encrypted. If your database leaks, hashed passwords cannot be reversed; encrypted ones can, the moment the key leaks too.
Defence
Use a slow, salted password hash (argon2id, bcrypt) — never a fast general-purpose hash like MD5 or SHA-256 for passwords. Fast is the attacker's friend here.
$ echo -n "hunter2" | argon2 somesalt -id
Encoded: $argon2id$v=19$m=4096,t=3,p=1$c29tZXNhbHQ$...
Recap
- A hash is a one-way fingerprint
- Passwords are hashed with a slow, salted algorithm