Make a vector of `size` pseudo-random bytes, deterministic for a given `seed`.
| 34 | |
| 35 | /// Make a vector of `size` pseudo-random bytes, deterministic for a given `seed`. |
| 36 | std::vector<uint8_t> MakeRandomBytes(size_t size, uint32_t seed = 56) { |
| 37 | std::vector<uint8_t> bytes(size); |
| 38 | std::minstd_rand gen(seed); |
| 39 | std::uniform_int_distribution<int> dist(0, 255); // no standard support for uint8_t |
| 40 | for (auto& byte : bytes) { |
| 41 | byte = static_cast<uint8_t>(dist(gen)); |
| 42 | } |
| 43 | return bytes; |
| 44 | } |
| 45 | |
| 46 | /// Read the first `count` bits of `bytes` (LSB first) into a vector of booleans. |
| 47 | std::vector<bool> BitsFromBytes(const std::vector<uint8_t>& bytes, rle_size_t count) { |
no outgoing calls
no test coverage detected