How to compare text input with a user password stored in the database?
The only advisable approach would be to use user_check_password:

$account = user_load(123);
$valid = user_check_password($password_from_form_submission, $account);
if ($valid) {...}


If you desperately need to do it manually, just copy the parts of that function that make sense for your requirements.