Hash method not providing password that is stored in database I created a custom form for the registration, but I am not getting how to store the password in hash format in the database.

I am using the following code, but I am not getting the value Drupal saves in the database for the password.

require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
echo user_hash_password('taliadmin');


Why am I getting a different value?
That's pretty much the point. user_hash_password uses _password_generate_salt, which in turn uses drupal_random_bytes. This means hash returned will always contain randomization and is designed not to return the same result twice. Or at least do it as rarely as possible, because there is 2^(6*8) possible outputs of 6 random bytes.

To test passwords, Drupal uses user_check_password. This function extracts salt from stored password and applies it to the one user provided.

Note that by design Drupal does not have any function that would allow to recreate hashes perfectly, and it's not possible to write one (without using original hash to extract salt, that is). You can get pretty close if you need to, copying logic from  user_check_password, but it is actually better to leave salt changing as much as possible.