How can the PHP code for password adjustment using md5 be modified to ensure compatibility between registration and password reset functionalities?

When using md5 for password hashing in PHP, the issue arises when the registration and password reset functionalities use different methods for hashing passwords. To ensure compatibility, both functionalities should use the same hashing method. One way to solve this is to create a function that handles password hashing and verification consistently throughout the application. This function can be called both during registration and password reset processes.

<?php

function hashPassword($password) {
    return md5($password);
}

// Registration process
$hashedPassword = hashPassword($_POST['password']);

// Password reset process
$hashedNewPassword = hashPassword($_POST['new_password']);

?>