How to create encrypted hash passwords for drupal 7

After searching over the Internet, I found out that using drupal 7, the password is no longer encrypted via md5.

What are the possible ways to get passwords encrypted in Drupal 7 ??

+4
source share
3 answers

With drupal 7, the password is no longer encrypted via md5. There are several ways to get / set a password in drupal7. Using drush (for your information not used in your case):

drush upwd admin --password="newpassword"

Without drush, if you have cli-access to the server: (for your information not used in your case)

cd <drupal root directory>

PHP s/password-hash.sh 'myPassword'

Now copy the resulting hash and paste it into the request:

update users set name='admin', pass='pasted_big_hash_from_above' where uid=1;
+8
source

Thanks Malik.

.

, , , password.php, :

<?php
if (isset($_GET['p'])) {
  require_once dirname(__FILE__) . '/includes/bootstrap.inc';
  require_once dirname(__FILE__) . '/includes/password.inc';
  print _password_crypt('sha512', $_GET['p'], _password_generate_salt(DRUPAL_HASH_COUNT));
  exit();
}
print "No password to hash.";

, : http://domain.tld/password.php? p = 'MyPassword'. . , . , , _password_crypt() _password_generate_salt()

+3

user_hash_password() -, - Drupal, bootuprap Drupal .

chdir("/path/to/drupal");
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
user_hash_password($password);
+3

Source: https://habr.com/ru/post/1537841/


All Articles