Adaptive hashing
BCrypt is designed to be slow. The cost factor lets you increase work required as hardware gets faster, keeping brute-force attacks expensive over time.
password_hash()
PHP's built-in password_hash() handles salting automatically. Never roll your own implementation — always use password_hash() and password_verify().
Choosing cost
Cost 10 = ~100ms, Cost 12 = ~300ms, Cost 14 = ~1.2s. Choose the highest cost where login stays under 1 second on your server.
Never use MD5/SHA1
MD5 and SHA1 are designed to be fast — terrible for passwords. Always use BCrypt, Argon2, or scrypt for password hashing.
Password hashing, session security, JWT, and OAuth — covered in our PHP developer ebooks and courses.