MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / randomBytes

Function randomBytes

KittyMemoryEx/KittyUtils.cpp:6–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4{
5
6 std::vector<uint8_t> randomBytes(std::size_t length)
7 {
8 static std::mutex mtx;
9 std::lock_guard<std::mutex> lock(mtx);
10
11 static std::mt19937 gen{std::random_device{}()};
12
13 std::uniform_int_distribution<uint16_t> dist(0, 255);
14
15 std::vector<uint8_t> data(length);
16 for (auto &b : data)
17 {
18 b = static_cast<uint8_t>(dist(gen));
19 }
20
21 return data;
22 }
23
24 std::string randomString(size_t length)
25 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected