9 #include <boost/random/independent_bits.hpp> 20 using random_bytes_engine = boost::random::independent_bits_engine<
24 random_bytes_engine rbe;
26 std::generate(buffer->begin(), buffer->end(), std::ref(rbe));
31 length =
std::min(static_cast<size_t>(buf.
size()), length);
32 auto buffer = std::make_unique<char[]>(2u * length + 1u);
33 for (
auto i = 0u; i < length; ++i)
34 sprintf(&buffer[2u * i],
"%02x", buf.
data()[i]);
35 if (length < buf.
size())
36 return std::string(buffer.get()) + std::string(
"...");
37 return std::string(buffer.get());
const value_type * data() const noexcept
Direct access to the allocated memory or nullptr if no memory is allocated.
static shared_buffer make_empty(size_t size=0u)
std::shared_ptr< Buffer > shared_buffer
double min(double v1, double v2)
std::string to_hex_string(const Buffer &buf, size_t length)
shared_buffer make_random(size_t size)
size_type size() const noexcept