19 using random_bytes_engine = std::independent_bits_engine<
23 random_bytes_engine rbe;
25 std::generate(buffer->begin(), buffer->end(), [&rbe]() {
26 return static_cast<unsigned char>(rbe());
32 length = std::min(
static_cast<size_t>(buf.
size()), length);
33 auto buffer = std::make_unique<char[]>(2u * length + 1u);
34 for (
auto i = 0u; i < length; ++i)
35 sprintf(&buffer[2u * i],
"%02x", buf.
data()[i]);
36 if (length < buf.
size())
37 return std::string(buffer.get()) + std::string(
"...");
38 return std::string(buffer.get());
const value_type * data() const noexcept
Direct access to the allocated memory or nullptr if no memory is allocated.
size_type size() const noexcept
static shared_buffer make_empty(size_t size=0u)
std::shared_ptr< Buffer > shared_buffer
std::string to_hex_string(const Buffer &buf, size_t length)
shared_buffer make_random(size_t size)