What are the potential pitfalls of using MD5 for password hashing in PHP, and what alternatives, like bcrypt, should be considered for secure password storage?
Using MD5 for password hashing in PHP is not secure because it is a fast hashing algorithm that can be easily cracked using modern hardware. Instead, bcrypt should be considered for secure password storage as it is a slow hashing algorithm that is designed to be computationally expensive, making it much more difficult for attackers to crack passwords.
// Using bcrypt for secure password hashing
$password = "password123";
$hashed_password = password_hash($password, PASSWORD_BCRYPT);
// Verify password
if (password_verify($password, $hashed_password)) {
echo "Password is correct";
} else {
echo "Password is incorrect";
}