bytes generation¶
- group turbo_random_bytes
Functions
-
template<typename URBG>
void random_bytes(URBG &&urbg, void *output, size_t output_length)¶ turbo::random_bytes(urbg, output, output_length) fills the range [output, output + output_length) with uniformly distributed random bytes.
outputmust be a pointer to a range of at leastoutput_lengthbytes.urbgmust be a uniform random bit generator. See https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution.Example:
cpp turbo::BitGen bitgen; ... std::vector<uint8_t> bytes(100); turbo::random_bytes(bitgen, bytes.data(), bytes.size());
- Template Parameters:
URBG –
- Parameters:
urbg –
output –
output_length –
-
void random_bytes(void *output, size_t output_length)¶
similar to turbo::random_bytes(urbg, output, output_length), but uses the default thread-local bit generator.
See also
turbo::get_tls_bit_gen()
See also
turbo::set_tls_bit_gen()
Note
the default bitgen is thread_local. so it is thread safe.
- Parameters:
output –
output_length –
-
void fast_random_bytes(void *output, size_t output_length)¶
similar to turbo::random_bytes(urbg, output, output_length), but uses the fast thread-local bit generator.
See also
turbo::get_tls_fast_bit_gen()
See also
turbo::set_tls_fast_bit_gen()
Note
the fast bitgen is thread_local. so it is thread safe.
- Parameters:
output –
output_length –
-
template<typename URBG>
std::string random_printable(URBG &&urbg, size_t length)¶ turbo::random_bytes(output, output_length) fills the range [output, output + output_length) with uniformly distributed random bytes.
outputmust be a pointer to a range of at leastoutput_lengthbytes. the generated bytes are printable.- Parameters:
output – the output buffer
output_length –
-
std::string random_printable(size_t length)¶
similar to turbo::random_printable(urbg, output, output_length), but uses the default thread-local bit generator.
See also
turbo::get_tls_bit_gen()
See also
turbo::set_tls_bit_gen()
Note
the default bitgen is thread_local. so it is thread safe.
- Parameters:
output –
output_length –
-
std::string fast_random_printable(size_t length)¶
similar to turbo::random_printable(urbg, output, output_length), but uses the fast thread-local bit generator.
See also
turbo::get_tls_fast_bit_gen()
See also
turbo::set_tls_fast_bit_gen()
Note
the fast bitgen is thread_local. so it is thread safe.
- Parameters:
output –
output_length –
-
template<typename URBG>