drupal mysql hash密码_變更drupal7用戶密碼加密方式
在drupal程序的includes文件夾下添加 mypassword.inc 文件,文件內(nèi)容如下:
DEBUG mypassword.inc _password_crypt::password = '" . $password . "'";
return md5($password);
}
/**
* Parse the log2 iteration count from a stored hash or setting string.
*/
function _password_get_count_log2($setting) {
$itoa64 = _password_itoa64();
return strpos($itoa64, $setting[3]);
}
/**
* Hash a password using a secure hash.
*
* @param $password
* A plain-text password.
* @param $count_log2
* Optional integer to specify the iteration count. Generally used only during
* mass operations where a value less than the default is needed for speed.
*
* @return
* A string containing the hashed password (and a salt), or FALSE on failure.
*/
function user_hash_password($password, $count_log2 = 0) {
return _password_crypt($password);
}
/**
* Check whether a plain text password matches a stored hashed password.
*
* Alternative implementations of this function may use other data in the
* $account object, for example the uid to look up the hash in a custom table
* or remote database.
*
* @param $password
* A plain-text password
* @param $account
* A user object with at least the fields from the {users} table.
*
* @return
* TRUE or FALSE.
*/
function user_check_password($password, $account) {
$stored_hash = $account->pass;
$hash = _password_crypt($password);
//echo "
DEBUG mypassword.inc user_check_password::stored_hash = '" . $stored_hash . "'";
//echo "
DEBUG mypassword.inc user_check_password::hash = '" . $hash . "'";
return ($hash && $stored_hash == $hash);
}
/**
* Check whether a user's hashed password needs to be replaced with a new hash.
*
* This is typically called during the login process when the plain text
* password is available. A new hash is needed when the desired iteration count
* has changed through a change in the variable password_count_log2 or
* DRUPAL_HASH_COUNT or if the user's password hash was generated in an update
* like user_update_7000().
*
* Alternative implementations of this function might use other criteria based
* on the fields in $account.
*
* @param $account
* A user object with at least the fields from the {users} table.
*
* @return
* TRUE or FALSE.
*/
function user_needs_new_hash($account) {
// Check whether this was an updated password.
if ((strlen($account->pass) != DRUPAL_HASH_LENGTH)) {
return TRUE;
}
return FALSE;
// Ensure that $count_log2 is within set bounds.
//$count_log2 = _password_enforce_log2_boundaries(variable_get('password_count_log2', DRUPAL_HASH_COUNT));
// Check whether the iteration count used differs from the standard number.
//return (_password_get_count_log2($account->pass) !== $count_log2);
}
?>
總結(jié)
以上是生活随笔為你收集整理的drupal mysql hash密码_變更drupal7用戶密碼加密方式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【小月电子】ALTERA FPGA开发板
- 下一篇: 让传感器数据在三维地图上显示,更直观,更