本文整理汇总了PHP中PasswordHash::hash_password方法的典型用法代码示例。如果您正苦于以下问题:PHP PasswordHash::hash_password方法的具体用法?PHP PasswordHash::hash_password怎么用?PHP PasswordHash::hash_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PasswordHash
的用法示例。
在下文中一共展示了PasswordHash::hash_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_update
/**
* Updates the given user.
*
* @param string $old_user
* The old username.
* @param string $user
* The new user.
* @param string $pass
* The new password.
* The new user. (Optional, default = null)
* @param string $group
* The new group. (Optional, default = null)
*
* @return boolean
* True if success, else false.
*/
public function user_update($old_user, $user, $pass = null, $group = null)
{
$values = array(':user' => $user, ':old_user' => $old_user, ':group' => $group);
$pw = '';
if ($pass !== null) {
$pw_hash = new PasswordHash();
$pw = ', "password" = :password';
$values[':password'] = $pw_hash->hash_password($pass);
}
return Db::getInstance()->exec('UPDATE "users" SET "username" = :user' . $pw . ', "group" = :group WHERE "username" = :old_user', $values);
}
示例2: array
/**
* New page
*
* New page description
*
* @access public
* @param none
* @return redirect
* @route n/a
*/
function create_user($userdata = array())
{
$hasher = new PasswordHash();
$text_password = $userdata['user_pass'];
$userdata['user_pass'] = $hasher->hash_password($userdata['user_pass']);
$userdata['user_ip'] = $this->CI->input->ip_address();
$this->CI->db->set('register_date', 'NOW()', false)->insert('users', $userdata);
$user_id = $this->CI->db->insert_id();
$this->signin($userdata['username'], $text_password);
return $user_id;
}