#include "../random.h"

#define NOMINMAX
#include <windows.h>
#include <bcrypt.h>
#pragma comment(lib, "bcrypt.lib")

namespace netplus {
    void fillRandomBytes(uint8_t* dst, size_t len) {
        if (!dst || len == 0) return;

        NTSTATUS status = BCryptGenRandom(
            nullptr,
            reinterpret_cast<PUCHAR>(dst),
            (ULONG)len,
            BCRYPT_USE_SYSTEM_PREFERRED_RNG
        );

        if (status != 0) {
            throw std::runtime_error("BCryptGenRandom failed");
        }
    }
}
