DAY 8 OF MY BACKEND JOURNEY
Password Hashing and Security with bcryptjs
Today, I deepened my understanding of one of the most critical aspects of backend development: protecting user passwords. I learned that plain-text passwords are inexcusable, and even fast hashing algorithms like MD5 or SHA-1 leave systems vulnerable to brute-force and rainbow-table attacks.
Learning with
@Nannoyapp
β I discovered why adaptive hashing algorithms like bcryptjs are the industry standard. Unlike fast hashes, bcryptjs has a configurable cost factor (salt rounds) that can be increased as hardware improves, making it future-proof against computational advances.
β I learned the registration flow: hash the incoming password with bcrypt.hash() using at least 10 salt rounds before storing it in the database, ensuring that even if breached, attackers see hashes, not passwords.
β I understood the login verification process: use
bcrypt.compare() to check if the plain-text password matches the stored hash. This function is timing-safe, preventing side-channel attacks where response time could leak information about where strings differ.
β I implemented proper error handling by returning a generic "Invalid credentials" message for both missing usernames and wrong passwords, refusing to reveal which one failed, a security best practice that prevents username enumeration attacks.
β I learned that salt rounds matter: 10 rounds takes ~65ms and is the production minimum, while 12 rounds (~250ms) is recommended for 2026. Benchmarking on production hardware is essential to balance security and user experience.
OMO!
I faced infrastructure challenges todayπ€¦ββοΈ: power supply issues disrupted my session. I installed Postman to test my endpoints oo, but it wasn't responding.
So I switched to curl commands in the terminal to verify my hashing and login flows, but my PC went off right when I was about to run the tests. Frustrating timing, but the knowledge stuck with me.
The journey continues, sometimes the hardest part isn't the code, it's fighting the hardware! π
Good evening everyone!