Hi,

I am trying to import the users from the existing drupal site to another drupal instance. I have exported all the users into a csv file using mysql command. I got all the users with their Encrypted passwords. I was trying to unencrypt the encrypted passwords but it was not possible for me.

Is it possible to map the password of the user with Encrypted password or let me know whether we can unecrypt md5 password?

Comments

dgastudio’s picture

also need it.

franz’s picture

Priority: Critical » Normal
Status: Needs work » Active

If you could easily unencrypt md5, it would not be secure, right?

No feature request is ever "critical". This could be achieved using a custom mapper. See the feeds.api.php file to learn how to do it.

zarkinfrood’s picture

does the importer in feeds encrypt the password automatically?

There is a solution for converting an md5 to D7 SHA hash, but would require a separate process. Has anyone found a solution for this?

Would hate to have to do this by hand given the other fields my users need.

Jalandhar’s picture

Status: Active » Needs review

We have to create a page named something like rehash.php (in your root, same place as update.php). Then, log in as administrator first, browse to this page second. Please find the below code

(Note : Skipped the hashing for the admin user having uid=1 in the below code ).

    // bootstrap stuff
    define('DRUPAL_ROOT', getcwd());

    include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

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

    // Lower than DRUPAL_HASH_COUNT to make the update run at a reasonable speed.
    $hash_count_log2 = 11;

    //  Hash again all current hashed passwords.
    $has_rows = FALSE;

    // Update this many users
    $count = 1000;

    $result = db_query_range("SELECT uid, pass FROM {users} WHERE uid > 1 ORDER BY uid", 0, $count);
    foreach ($result as $account) {
      $has_rows = TRUE;
      $new_hash = user_hash_password($account->pass, $hash_count_log2);
      if ($new_hash) {
        // Indicate an updated password.
        $new_hash  = 'U' . $new_hash;
        db_update('users')
          ->fields(array('pass' => $new_hash))
          ->condition('uid', $account->uid)
          ->execute();
      }
    }
MegaChriz’s picture

Status: Needs review » Closed (duplicate)

This looks like a duplicate of #1611554: Support for encrypted passwords. If I'm mistaken, you may reopen this issue.