什么是Drupal的默认密码加密方法?

Chr*_*ams 43 php mysql drupal

我试图弄清楚Drupal 6/7默认使用什么安全性来存储密码.是MD5,AES,SHA吗?我一直找不到任何东西.

Cal*_*ebD 69

Drupal 8和Drupal 7默认使用SHA512和盐.它们通过PHP的散列函数多次运行散列,以增加生成密码的最终散列(称为拉伸的安全技术)的计算成本.

使用Drupal 8,实现是面向对象的.有一个PasswordInterface定义了一个哈希方法.该接口的默认实现位于PhpassHashedPassword类中.该类的哈希方法调用传递SHA512 的crypt方法作为哈希算法,密码和生成的盐.类的crypt方法与Drupal 7的_password_crypt()方法几乎相同.

使用Drupal 7,实现分为几个全局函数:user_hash_password()_password_crypt().

Drupal 6使用不含盐的MD5.相关函数是user_save().


Ray*_*lha 32

以下是Drupal 7的示例哈希:

  • "通过":"$ S $ Dxl65W9p07LfQU7jvy5CnsyDpMoLujiAgzy123khcg1OJi/P9pKS"

  • 字符0-2是类型($ S $是Drupal 7)

  • 字符3是基于此列表中char的位置的log2轮数(X):'.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'所以在我们的示例中'D'将映射到15
  • 字符4-11是SALT
  • 其余的是使用2 ^ X轮的SHA512哈希.
  • 然后使用base64将二进制结果转换为字符串.

    $ count = 1 << $ count_log2;
    $ hash = hash($ algo,$ salt.$ password,TRUE);
    do {$ hash = hash($ algo,$ hash.$ password,TRUE);
    } while( - $ count);

整个过程可以在:mydrupalsite\includes\password.inc中找到


Tar*_*pta 11

可以在www\includes\password.inc中查看

function user_check_password($password, $account) {
  if (substr($account->pass, 0, 2) == 'U$') {
    // This may be an updated password from user_update_7000(). Such hashes
    // have 'U' added as the first character and need an extra md5().
    $stored_hash = substr($account->pass, 1);
    $password = md5($password);
  }
  else {
    $stored_hash = $account->pass;
  }

  $type = substr($stored_hash, 0, 3);
  switch ($type) {
    case '$S$':
      // A normal Drupal 7 password using sha512.
      $hash = _password_crypt('sha512', $password, $stored_hash);
      break;
    case '$H$':
      // phpBB3 uses "$H$" for the same thing as "$P$".
    case '$P$':
      // A phpass password generated using md5.  This is an
      // imported password or from an earlier Drupal version.
      $hash = _password_crypt('md5', $password, $stored_hash);
      break;
    default:
      return FALSE;
  }
  return ($hash && $stored_hash == $hash);
}
Run Code Online (Sandbox Code Playgroud)

它清楚地写着"//使用sha512正常的Drupal 7密码."


Dav*_*len 5

它是MD5,据我所知,没有任何盐渍使用.编辑 - 这是drupal 6.对于drupal 7,使用了一些更高级的哈希.这里有一篇很好的文章 - http://joncave.co.uk/2011/01/password-storage-in-drupal-and-wordpress/