How can developers ensure the security of user credentials when using HTTP-Authentifizierung for login?

Developers can ensure the security of user credentials when using HTTP-Authentifizierung for login by encrypting the passwords before storing them in the database. This way, even if the credentials are intercepted during the authentication process, they will be useless to the attacker.

// Encrypt the password before storing it in the database
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);

// Verify the password during login
if(password_verify($_POST['password'], $stored_password)) {
    // Password is correct
} else {
    // Password is incorrect
}