What is the difference between encryption and hashing in PHP, and how does it relate to the use of md5() for password storage?

Encryption is the process of converting data into a format that can only be read or understood by someone who has the key to decrypt it. Hashing, on the other hand, is a one-way process that converts data into a fixed-size string of characters, making it impossible to reverse the process and obtain the original data. When it comes to storing passwords in PHP, it is recommended to hash the passwords using a secure hashing algorithm like bcrypt instead of using the md5() function, which is not secure for password storage.

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

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