31 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
32 std::mt19937 g_engine {1};
37 return std::uniform_int_distribution<int32_t>(0, maximum-1)(g_engine);
45 const char *charset) {
46 size_t in_i = 0, out_i = 0;
55 size_t set_len = strlen(chars);
57 assert(set_len > 0 && set_len <= 256);
60 u32 = std::uniform_int_distribution<uint32_t>()(g_engine);
64 buf[out_i++] = chars[in[in_i] % set_len];
69 buf[out_i++] = chars[in[in_i] % set_len];
74 buf[out_i++] = chars[in[in_i] % set_len];
79 buf[out_i++] = chars[in[in_i] % set_len];
int32_t random_int32(int32_t maximum)
Generate random 32-bit integer.
Compatibility Macros for C/C++.
void random_fill_with_chars(char *buf, size_t len, const char *charset=nullptr)
Fills a buffer with random values from a set of characters.
void random_generator_set_seed(unsigned seed)
Sets random number generator seed.