What potential issue could arise when using MD5 encoding for passwords in PHP?
Using MD5 encoding for passwords in PHP is not secure because MD5 is considered a weak hashing algorithm and can be easily cracked using modern computing power. To solve this issue, it is recommended to use a more secure hashing algorithm like bcrypt or Argon2 for password hashing in PHP.
// Hashing a password using bcrypt
$password = "password123";
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);
// Verifying a password using bcrypt
$enteredPassword = "password123";
if (password_verify($enteredPassword, $hashedPassword)) {
echo "Password is correct!";
} else {
echo "Password is incorrect!";
}