php-Drupal的默认密码加密方法是什么?
我试图弄清楚Drupal 6/7默认使用什么安全性来存储密码。 是MD5,AES,SHA吗? 我一直找不到任何东西。
5个解决方案
68 votes
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()。
CalebD answered 2020-08-09T16:23:30Z
32 votes
这是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);
做{$ hash = hash($ algo,$ hash。$ password,TRUE);
} while(-$ count);
整个过程可以在以下位置找到:mydrupalsite \ includes \ password.inc
Ray Hulha answered 2020-08-09T16:24:39Z
11 votes
可以在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);
}
它清楚地写为“ //使用sha512的普通Drupal 7密码”。
Tarun Gupta answered 2020-08-09T16:25:04Z
5 votes
对于Drupal 6核心,该方法使用MD5,据我了解,没有使用任何盐化方法。 对于drupal 7,使用了一些更高级的哈希。 一篇不错的文章-[http://joncave.co.uk/2011/01/password-storage-in-drupal-and-wordpress/]
David Gillen answered 2020-08-09T16:25:24Z
0 votes
drupal 8正在使用Phpass(修改版)
drupal 7使用SHA-512 +盐
drupal 6和先前版本使用不含盐的md5
user889030 answered 2020-08-09T16:25:52Z