C# (.NET)

For the .NET Framework 4.7 and .NET Core 8.0

🐼 Panda-Pelican vClient-API - .NET Documentation

The Panda-Pelican vClient-API (where vClient stands for Vanguard Client) is a .NET library designed to provide secure key validation and hardware authentication for your C# applications.

✨ Core Features

  • 🔑 Secure Key Validation: Robust validation against the Panda Development services.

  • 💻 Hardware Authentication (HWID): Automatic hardware fingerprinting and association.

  • 🛡️ Proxy Detection: Built-in mechanisms to detect and manage proxy usage.

  • 🐛 Debugger Protection: Anti-debugging measures to protect your application and the validation process.

⚙️ Installation

  1. Add DLL Reference:

    • Download the Panda-Pelican vClient-API.dll file.

    • In your Visual Studio project, right-click on "References" (or "Dependencies" for .NET Core/5+) in the Solution Explorer.

    • Select "Add Reference..."

    • Browse to and select the Panda-Pelican vClient-API.dll file.

  2. Install Required NuGet Packages: You'll need the following NuGet packages. You can install them via the NuGet Package Manager Console or the Manage NuGet Packages UI:

    • Newtonsoft.Json: For JSON parsing.

      Install-Package Newtonsoft.Json 
    • System.Management: For accessing system management information (often used for HWID generation).

      Install-Package System.Management

      (Note: System.Management is primarily for .NET Framework. For .NET Core/.NET 5+, HWID generation might be handled differently within the library or require platform-specific approaches if you were implementing it yourself.)

🚀 Quick Start

Here's a basic example of how to initialize the client and validate a key:

using PandaPelican.vClient; 
using System;
using System.Threading.Tasks;

public class Example
{
    public static async Task Main(string[] args)
    {
        // Initialize the client with your unique service ID
        var client = new Client("your_service_id");

        // Get user's key (e.g., from input or configuration)
        string userKey = "user_key_here";

        Console.WriteLine($"Validating key: {userKey}...");
        bool isValid = await client.ValidateKey(userKey);

        if (isValid)
        {
            Console.WriteLine("Key is VALID!");
            // You can now get more information about the key
            var keyInfo = client.GetKeyInformation();
            if (keyInfo != null)
            {
                Console.WriteLine($"Key Value: {keyInfo.Key}");
                Console.WriteLine($"Is Premium: {keyInfo.IsPremium}");
                Console.WriteLine($"Expires On: {keyInfo.ExpireDate}");
            }
        }
        else
        {
            Console.WriteLine("Key is INVALID.");
        }

        // Get Hardware ID
        string hwid = client.GetHWID();
        Console.WriteLine($"Current Hardware ID: {hwid}");

        // To open the key browser (e.g., for users to purchase/activate a key)
        // client.LaunchKeyBrowser();
    }
}
    

📚 API Reference

Client Class

The main class for interacting with the vClient API.

Namespace: (Assuming PandaPelican.vClient or similar. Please verify from the DLL.)

Constructor

Initializes a new instance of the Client class.

  • Parameters:

    • serviceId (string): Your unique service identifier provided by Panda Development. Required.

Methods

Asynchronously validates the provided license key against your service.

  • Parameters:

    • key (string): The license key to validate. Required.

  • Returns: Task<bool> - true if the key is valid; otherwise, false.

Retrieves information about the last successfully validated key. This should be called after a successful ValidateKey operation.

  • Returns: Client.KeyInformation object containing details about the key, or null if no key has been successfully validated or if information is unavailable.

  • KeyInformation Properties:

    • Key (string): The validated license key string.

    • IsPremium (bool): Indicates if the key is a premium key.

    • ExpireDate (DateTime): The expiration date and time of the key.

Gets the current machine's Hardware ID (HWID) as determined by the library. This HWID is automatically used during key validation.

  • Returns: string - The generated Hardware ID.

Opens the default web browser to the key purchase/activation page associated with your service, pre-filling the HWID if the page supports it.


💡 Examples

Detailed Async Key Validation and Information Retrieval

using PandaPelican.vClient;
using System;
using System.Threading.Tasks;

public class KeyValidationDemo
{
    private Client apiClient;

    public KeyValidationDemo(string serviceId)
    {
        apiClient = new Client(serviceId);
    }

    public async Task CheckKey(string userKey)
    {
        Console.WriteLine($"Attempting to validate key: {userKey}");
        bool isValid = await apiClient.ValidateKey(userKey);

        if (isValid)
        {
            Console.WriteLine("Key validation successful!");
            var keyInfo = apiClient.GetKeyInformation();
            if (keyInfo != null)
            {
                Console.WriteLine("--- Key Information ---");
                Console.WriteLine($"  Key: {keyInfo.Key}");
                Console.WriteLine($"  Is Premium: {keyInfo.IsPremium}");
                Console.WriteLine($"  Expires: {keyInfo.ExpireDate.ToString("yyyy-MM-dd HH:mm:ss")}");
                Console.WriteLine("-----------------------");
            }
            else
            {
                Console.WriteLine("Could not retrieve key information even though key was valid.");
            }
        }
        else
        {
            Console.WriteLine("Key validation FAILED.");
            // You might want to check a client-side error property if available,
            // or rely on the bool return and potentially an event/callback for detailed errors.
        }
    }
}
    

🖥️ Windows Forms Example

This example demonstrates integrating key validation into a simple Windows Forms application. (You can download a SampleGUI from your Panda Development Dashboard).

Assumptions:

  • A Form with:

    • keyTextBox (TextBox) for key input.

    • validateButton (Button) to trigger validation.

    • statusLabel (Label) to display status.

// Add these using statements at the top of your Form1.cs
using PandaPelican.vClient; 
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading.Tasks; // Required for async operations

public partial class Form1 : Form
{
    private readonly Client client;

    public Form1()
    {
        InitializeComponent();
        // IMPORTANT: Replace "your_service_id" with your actual service ID
        client = new Client("your_service_id");
    }

    private async void validateButton_Click(object sender, EventArgs e)
    {
        try
        {
            // Disable controls during validation
            validateButton.Enabled = false;
            keyTextBox.Enabled = false;
            statusLabel.Text = "Validating...";
            statusLabel.ForeColor = Color.Orange;

            string key = keyTextBox.Text.Trim();

            if (string.IsNullOrEmpty(key))
            {
                statusLabel.Text = "Key cannot be empty!";
                statusLabel.ForeColor = Color.Red;
                return; // Exit validation early
            }

            bool isValid = await client.ValidateKey(key);

            if (isValid)
            {
                statusLabel.Text = "Authenticated";
                statusLabel.ForeColor = Color.Green;

                // Optionally, display key information
                var keyInfo = client.GetKeyInformation();
                if (keyInfo != null)
                {
                    MessageBox.Show($"Key: {keyInfo.Key}\nPremium: {keyInfo.IsPremium}\nExpires: {keyInfo.ExpireDate}", "Key Details");
                }
            }
            else
            {
                statusLabel.Text = "Authentication Failed";
                statusLabel.ForeColor = Color.Red;
            }
        }
        catch (Exception ex)
        {
            statusLabel.Text = "Error during validation.";
            statusLabel.ForeColor = Color.DarkRed;
            MessageBox.Show($"An error occurred: {ex.Message}", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        finally
        {
            // Re-enable controls
            validateButton.Enabled = true;
            keyTextBox.Enabled = true;
        }
    }

    // Example: Launch key browser button
    private void launchBrowserButton_Click(object sender, EventArgs e)
    {
        try
        {
            client.LaunchKeyBrowser();
        }
        catch (Exception ex)
        {
            MessageBox.Show($"Could not launch browser: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}
    

🛡️ Security Features

The vClient API is designed with security in mind and automatically handles several protection mechanisms:

  • Proxy Detection & Management: The library attempts to detect users connecting through proxies, which can be a common method to bypass licensing restrictions.

  • Anti-Debugging Protection: Includes measures to make it more difficult for malicious users to debug your application and tamper with the validation process.

  • Hardware Fingerprinting: GetHWID() and the internal HWID mechanisms create a fingerprint of the user's machine for robust hardware-locked licensing.

⚠️ Error Handling

  • The ValidateKey method returns a boolean. Always check this return value.

  • GetKeyInformation may return null. Always check for null before accessing its properties.

  • Wrap API calls, especially ValidateKey and LaunchKeyBrowser, in try-catch blocks to handle potential exceptions (e.g., network issues, configuration errors).

☁️ Download

767KB
Open

Last updated