> For the complete documentation index, see [llms.txt](https://easyauth.papelship.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easyauth.papelship.com/documentation/core-functions/variables-files.md).

# Variables Files

EasyAuth allows developers to store sensitive configuration strings, offsets, decryption keys, and large binary payloads (up to 150 MB) securely in the cloud, fetching them on-demand via encrypted channels.

## Cloud Encrypted Variables

### `easyauth::get_variable`

Fetches a decrypted server-side variable or secret string.

```cpp
std::string get_variable(const std::string& access_id, const std::string& key = "", const std::string& api_key = "");
```

#### Parameters

* `access_id`: The identifier name of the variable created on the EasyAuth Dashboard.
* `key` *(Optional)*: License key if the variable is restricted to authenticated users.
* `api_key` *(Optional)*: Product API key.

#### Returns

A decrypted `std::string` containing the variable value, or empty string on failure.

#### Example

```cpp
// Fetch a public server string (no license key required)
std::string motd = easyauth::get_variable("motd_banner");

// Fetch a protected cheat offset / API secret (requires valid license key)
std::string game_offset = easyauth::get_variable("dwLocalPlayer", user_key, api_key);
std::cout << "[+] Game Offset: " << game_offset << "\n";
```

### `easyauth::get_variable_ex`

Extended version of `get_variable` that returns a detailed status structure.

```cpp
variable_result get_variable_ex(const std::string& access_id, const std::string& key = "", const std::string& api_key = "");
```

#### Return Structure (`variable_result`)

```cpp
struct variable_result {
    bool success;           // true if variable was retrieved and decrypted
    std::string value;      // Variable payload content
    std::string type;       // Variable data type ("string", "json", "base64", etc.)
    std::string error_name; // Error code (e.g. "VAR_NOT_FOUND", "KEY_REQUIRED")
    std::string message;    // Detailed status
};
```

## Cloud File Streaming (Up to 150 MB)

EasyAuth supports streaming large encrypted binaries, cheat DLLs, drivers, and asset files in high-speed 64 KB encrypted chunks directly into client RAM.

### `easyauth::get_file`

Streams an entire cloud file into an in-memory byte buffer (`std::vector<uint8_t>`).

```cpp
file_download_result get_file(
    const std::string& access_id,
    const std::string& key = "",
    const std::string& api_key = "",
    download_progress_callback progress_cb = nullptr
);
```

#### Progress Callback Prototype

```cpp
typedef void (*download_progress_callback)(size_t downloaded_bytes, size_t total_bytes, float percentage);
```

#### Example

```cpp
void on_download_progress(size_t downloaded, size_t total, float percentage) {
    std::cout << "\r[*] Downloading: " << downloaded << "/" << total 
              << " bytes (" << (int)percentage << "%)" << std::flush;
}

// Stream encrypted payload into memory
auto file_res = easyauth::get_file("core_payload_dll", user_key, api_key, on_download_progress);
if (file_res.success) {
    std::cout << "\n[+] File successfully streamed into memory! Size: " << file_res.file_size << " bytes.\n";
    // Access raw decrypted bytes via file_res.data
}
```

### `easyauth::download_file_to_disk`

Downloads and writes a cloud file directly to a specified local disk path.

```cpp
bool download_file_to_disk(
    const std::string& access_id,
    const std::string& output_path = "",
    const std::string& key = "",
    const std::string& api_key = "",
    download_progress_callback progress_cb = nullptr
);
```
