How can PHP be used to hash and salt passwords for secure login systems?
To hash and salt passwords for secure login systems in PHP, you can use the password_hash() function to hash the password and generate a unique salt for each password. This helps protect against rainbow table attacks and increases the security of the stored passwords.
$password = "password123";
$salt = uniqid(mt_rand(), true);
$hashed_password = password_hash($password . $salt, PASSWORD_DEFAULT);
// Store $hashed_password and $salt in the database