What encryption method can I use to securely store passwords in PHP?

Storing passwords securely in PHP involves using a strong encryption method, such as bcrypt, to hash the passwords before saving them in the database. This ensures that even if the database is compromised, the passwords cannot be easily decrypted.

// Hashing a password using bcrypt
$password = "mySecurePassword";
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);

// Verifying a password
$enteredPassword = "mySecurePassword";
if (password_verify($enteredPassword, $hashedPassword)) {
    echo "Password is correct";
} else {
    echo "Password is incorrect";
}