BareGit
#pragma once

#include <cstddef>
#include <cstdint>
#include <mutex>
#include <random>
#include <string>

/// Thread-safe pseudorandom values that must never be used as secrets.
class NonSecretRandom
{
public:
    /// Seed a production generator from std::random_device.
    NonSecretRandom();

    /// Seed a deterministic generator for tests.
    explicit NonSecretRandom(std::uint64_t seed);

    /// Return one uniformly distributed 32-bit value.
    std::uint32_t next();

    /// Return pseudorandom bytes encoded as lowercase hexadecimal.
    std::string hex(std::size_t byte_count);

private:
    std::mutex mutex_;
    std::mt19937_64 engine_;
};