Which function returns a password hash using Drupal-6?

I want to make a script to insert about 100 users into the Drupal 6 database - their username, password and password.

After reading about the PHP class that uses Drupal 6, I'm not sure I can do this. My method was to send a message like “Hello, x! Your new password is y” to each user, and then insert the hashed “y” into the Drupal user table.

I know that Drupal returns md5. But this is not just the original md5 password, but a very mixed password (using salt and other methods).

I looked at Portable PHP hashing frames . Using Drupal, but I don’t think it only works with the copy + paste method.

So my question is: can I make a PHP function that returns a valid Drupal 6 password hash to insert into my user table?

+6
php passwords drupal password-hash
source share
3 answers

Actually, Drupal 6 does not use salt to calculate the password hash. Its just just md5 password

You can try it for yourself. Set your password.

Calculate the md5 of your password (you can use this link http://www.miraclesalad.com/webtools/md5.php for convenience).

You will see that the hash stored in the database in the users table in the pass column will be exactly the same

This behavior for installing Drupal 6 by default can be changed for Drupal 7). Only if you have installed any special module will the behavior be different for Drupal 6.

+7
source share

If you create users programmatically, you must create the plaintext password yourself, and then use the user_save() function to insert the user into the database. This function will be a hash and save everything for you.

+4
source share

Existing custom imports look like they will work for bulk imports. This does not answer your question “How do I set a password”, but it saves you from having to configure (possibly more error prone) the script.

+2
source share

All Articles