implementing user has password in hook menu we are implementing a web service for a Drupal 7 site (the web service code is not part of drupal installation folder).

one of the web services needs to sign up the user on the site. 
the main hurdle was getting  a hashed password that Drupal will also recognize. 

for that , am following a suggestion made on stack overflow to Implement a REST service inside drupal and call that from the outside service code . (that part also seems possible and achieveable). 

have implemented a password hashing service with following code:

function GetHashedPassword($string)
{
    require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');

    $hashedpw = user_hash_password($string);

    $data = array(
        'password' =&gt; $hashedpw
    );

    header("Access-Control-Allow-Origin: *");

    drupal_json_output($data);
    drupal_exit();
}


the main issue now is that whenever this service is called even with same string , it returns a new hashed value each time.. 

kindly assist if what we need is actually even possible and if so, then what could be fixed in the above code

any help appreciated
If you check the functions being called, you'll there's a randomness in generating the hash for security reasons. I think that is not a problem. Have you tried using that as the stored password and logging in afterwards?