What are the potential security risks of using md5 to store passwords in a database?

Using md5 to store passwords in a database poses a security risk because md5 is a fast and easily reversible hashing algorithm. This means that if a hacker gains access to the database, they can quickly decrypt the hashed passwords using rainbow tables or brute force attacks. To enhance security, it is recommended to use a more secure hashing algorithm such as bcrypt or Argon2, which are slower and more resistant to decryption.

// Hashing a password using bcrypt
$hashed_password = password_hash($password, PASSWORD_BCRYPT);

// Verifying a password
if (password_verify($password, $hashed_password)) {
    // Password is correct
} else {
    // Password is incorrect
}