Skip to main content

What is PHP’s password_hash() and why is it recommended?

Mid PHP
Quick Answer password_hash() creates a secure hash using bcrypt or Argon2. It automatically generates and embeds a salt. password_verify() checks a plain password against the hash. Never use md5() or sha1() for passwords - they are fast and GPU-crackable. bcrypt is slow by design which makes brute-force attacks expensive. Always use these functions for storing user passwords.

Answer

password_hash() uses strong algorithms like bcrypt/argon2 with auto-salting, removing the need for manual security handling.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice