Skip to main content
Changed the answer and added the script used to update the passwords' format
Source Link
João Guilherme
  • 1.8k
  • 2
  • 16
  • 17

To update the md5 password to the hashed one I needneeded to use user_hash_password() and concact an 'U'. Here is the script that I used to make it work.

<?php
        require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
        $res = db_query('select * from drupal.users');

        if($res) {
                foreach ($res as $result) {
                        $hashed_pass = user_hash_password($result->pass, 11);
                        if ($hashed_pass) {
                          $hashed_pass  = 'U' . $hashed_pass;
                          db_update('users')->fields(array('pass' => $hashed_pass))->condition('uid', $result->uid)->execute();
                        }
                }
        }

Then I ran

drush scr <name_of_the_script_file>

And it worked.

To update the md5 to the hashed one I need to use user_hash_password().

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

 user_hash_password($result->pass, 11);

To update the md5 password to the hashed one I needed to use user_hash_password() and concact an 'U'. Here is the script that I used to make it work.

<?php
        require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
        $res = db_query('select * from drupal.users');

        if($res) {
                foreach ($res as $result) {
                        $hashed_pass = user_hash_password($result->pass, 11);
                        if ($hashed_pass) {
                          $hashed_pass  = 'U' . $hashed_pass;
                          db_update('users')->fields(array('pass' => $hashed_pass))->condition('uid', $result->uid)->execute();
                        }
                }
        }

Then I ran

drush scr <name_of_the_script_file>

And it worked.

Post Undeleted by João Guilherme
Post Deleted by João Guilherme
added the link to the documentation page for the function
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Found it ! To update the md5 to the hashed one I need to use the user_hash_password functionuser_hash_password().

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

 user_hash_password($result->pass, 11);

Found it ! To update the md5 to the hashed one I need to use the user_hash_password function

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

 user_hash_password($result->pass, 11);

To update the md5 to the hashed one I need to use user_hash_password().

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

 user_hash_password($result->pass, 11);
Source Link
João Guilherme
  • 1.8k
  • 2
  • 16
  • 17

Found it ! To update the md5 to the hashed one I need to use the user_hash_password function

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

 user_hash_password($result->pass, 11);