/** * Generates a random password drawn from the defined set of characters * @return string the password */ function bb_generate_password($length = 12, $special_chars = true) { return nxt_Pass::generate_password($length, $special_chars); }
/** * set_password() - Updates the user's password with a new encrypted one * * For integration with other applications, this function can be * overwritten to instead use the other package password checking * algorithm. * * @since 2.5 * @uses nxt_Pass::hash_password() Used to encrypt the user's password before passing to the database * * @param string $password The plaintext new user password * @param int $user_id User ID */ function set_password($password, $user_id) { $user = $this->get_user($user_id); if (!$user || is_nxt_error($user)) { return $user; } $user_id = $user->ID; $hash = nxt_Pass::hash_password($password); $this->update_user($user->ID, array('user_pass' => $password)); }
/** * Generates a random password drawn from the defined set of characters * * @since nxt 2.5 * * @param int $length The length of password to generate * @param bool $special_chars Whether to include standard special characters * @return string The random password */ function generate_password($length = 12, $special_chars = true) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; if ($special_chars) { $chars .= '!@#$%^&*()'; } $password = ''; for ($i = 0; $i < $length; $i++) { $password .= substr($chars, nxt_Pass::rand(0, strlen($chars) - 1), 1); } return $password; }