/** * 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; }