> For the complete documentation index, see [llms.txt](https://qpapel.papelship.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://qpapel.papelship.com/documentation/tr-documentation/proje-ayarlama/quick-start.md).

# Quick Start

Get your application up and running with qPapel Auth in just a few minutes.

{% hint style="info" %}
This guide assumes you have already completed the [Installation](broken://pages/65b7c10259920f894cc21b1166c68174f0f7378e) steps.
{% endhint %}

For a complete working repository that is ready to compile, check out our official C++ Console Example on GitHub:\
👉 [**GitHub: ProtectedAuth-CPP-Console-Example**](https://github.com/PapelShip/ProtectedAuth-CPP-Console-Example)

***

## Step 1: Get Your API Keys

{% tabs %}
{% tab title="Dashboard" %}
{% stepper %}
{% step %}
Log in to your web dashboard at [papelship.com](https://papelship.com/).
{% endstep %}

{% step %}
Navigate to **Dashboard → API Integrations → API Keys**.
{% endstep %}

{% step %}
Copy your keys:

* **API Key** (starts with `pk_`)

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Example Keys" %}

```
API Key: pk_00000073_1381695181994e4ea94eabf54911520b
```

{% hint style="warning" %}
This is an example key. Use your actual API keys from the dashboard.
{% endhint %}
{% endtab %}
{% endtabs %}

***

## Step 2: Create Your First Application

Create a new file `main.cpp` in your project's `Source` directory:

{% code title="main.cpp" %}

```cpp
#include <iostream>
#include <string>
#include <thread>
#include <chrono>
#include "qPapelLib.h"

// Link the static libraries via code (or configure in project settings)
#pragma comment(lib, "qPapelLib.lib")
#pragma comment(lib, "libsodium.lib")

int main() {
    std::cout << "--- PapelShip C++ Demo ---\n" << std::endl;
    std::cout << "[Loader] Initializing..." << std::endl;

    // 1. Initialize the loader stub (Decrypts & maps qPapelAuth DLL in memory)
    if (!qpapel::Init()) {
        std::cout << "[FAILED] Core stub initialization failed." << std::endl;
        return 1;
    }

    // 2. Create client context
    QPCTX ctx = qpapel::CreateContext();
    if (!ctx) {
        std::cout << "[FAILED] Could not allocate QPCTX." << std::endl;
        return 1;
    }

    // 3. Configure credentials (API Key, Server IP [empty for default], Port [0 for default], Client Version)
    qpapel::SetConfig(ctx, "pk_your_api_key_here", "", 0, "1.0.0");

    // 4. Run local integrity checks
    qpapel::CheckIntegrity(ctx);

    // 5. Connect to secure auth servers
    if (qpapel::Connect(ctx)) {
        std::cout << "[SUCCESS] Secure connection established." << std::endl;
        std::cout << "\n[Locked] Enter License Key: ";

        std::string licenseKey;
        std::cin >> licenseKey;

        std::cout << "[Auth] Validating key..." << std::endl;

        // 6. Authenticate license
        char* sessionToken = qpapel::Authenticate(ctx, licenseKey.c_str());

        if (sessionToken != nullptr) {
            std::cout << "[SUCCESS] License Validated!" << std::endl;
            std::cout << "Session Token: " << sessionToken << std::endl;
            
            // Free the allocated token buffer after use
            qpapel::FreeString(sessionToken);

            // --- Your protected application logic goes here ---
            std::cout << "\nWelcome to your protected application!" << std::endl;
            std::this_thread::sleep_for(std::chrono::seconds(3));
        }
        else {
            char* err = qpapel::GetLastStatus(ctx);
            std::cout << "[FAILED] Authentication failed: " << (err ? err : "Invalid Key") << std::endl;
            if (err) qpapel::FreeString(err);
        }
    }
    else {
        char* err = qpapel::GetLastStatus(ctx);
        std::cout << "[FAILED] Connection failed: " << (err ? err : "Unknown network error") << std::endl;
        if (err) qpapel::FreeString(err);
    }

    // 7. Cleanup context
    qpapel::DestroyContext(ctx);
    return 0;
}
```

{% endcode %}

***

## Step 3: Replace API Keys

{% hint style="danger" %}
Replace the `"pk_your_api_key_here"` placeholder with your actual API key from the web dashboard!
{% endhint %}

```cpp
qpapel::SetConfig(ctx, "pk_00000073_1381695181994e4ea94eabf54911520b", "", 0, "1.0.0");
```

***

## Step 4: Build and Pack

{% hint style="info" %}
Unlike traditional libraries, you cannot run your compiled `.exe` directly. You must run it through the `qPapelPacker` tool first to encrypt and embed the auth code.
{% endhint %}

{% tabs %}
{% tab title="Build" %}
{% stepper %}
{% step %}
Switch to **Release | x64** in Visual Studio.
{% endstep %}

{% step %}
Press **F7** or click **Build → Build Solution**.
{% endstep %}

{% step %}
If you configured the Post-Build Event in the installation guide, `dist/yourproject_final_x64.exe` will be generated automatically.

Expected output:

```
Embedding qPapelAuth DLL into target executable...
[OK] Pack complete! Distribute only: yourproject_final_x64.exe
========== Build: 1 succeeded, 0 failed ==========
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Manual Packing" %}
If you did not setup a post-build event, run this command manually in the terminal:

```bash
qPapelTools\qPapelPacker.exe --dll qPapelTools\qPapelAuth64.dll --input bin\example.exe --output dist\example_packed.exe
```

{% endtab %}
{% endtabs %}

***

## Step 5: Create a Test License

{% tabs %}
{% tab title="Dashboard" %}
{% stepper %}
{% step %}
Go to **Dashboard → Keys** on your Web Panel.
{% endstep %}

{% step %}
Click **"Generate New Key"**.
{% endstep %}

{% step %}
Configure:

* **Duration**: 30 days
* **Max Devices**: 1
* **Note**: "Test License"
  {% endstep %}

{% step %}
Click **"Create"**.
{% endstep %}

{% step %}
Copy the generated license key.
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Example Key" %}
Generated key example:

```
A1B2-C3D4-E5F6-G7H8
```

{% endtab %}
{% endtabs %}

***

## Step 6: Run & Verify

Launch the **packed** final executable (from `dist/` directory) and enter your license key:

```
--- PapelShip C++ Demo ---

[Loader] Initializing...
[SUCCESS] Secure connection established.

[Locked] Enter License Key: A1B2-C3D4-E5F6-G7H8
[Auth] Validating key...
[SUCCESS] License Validated!

Welcome to your protected application!
```

{% hint style="success" %}
Congratulations! Your application is now securely protected and active!
{% endhint %}

***

## Next Steps

Now that you have completed the basic validation flow, you can implement advanced features:

* **Real-time Heartbeat Monitor**: Add continuous background integrity/debugger checks via standard threads (see [Heartbeat Integration](broken://pages/7a4df74d2afaf30d31ce0ba9e17666013c844945)).
* **Server-Side Strings**: Store secrets on the server and fetch them safely in memory (see [Server-Side Strings](broken://pages/e5e63ca9726fbd5846c8c48bae3dd50878508bd1)).
* **Server-Side Files**: Securely download and execute remote dependencies (see [Server-Side Files](broken://pages/7410839880163a3b029ea2eda33ff8d2a40ca5ae)).
* **Process Loader (PE Injection)**: Seamlessly inject and run dynamic plugins or game cheats (see [PE Loader Integration](broken://pages/d6458560c376153701a4115ee27b06238473cd79)).
