MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / random_string

Function random_string

external/httplib.h:5023–5043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5021};
5022
5023inline std::string random_string(size_t length) {
5024 static const char data[] =
5025 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
5026
5027 // std::random_device might actually be deterministic on some
5028 // platforms, but due to lack of support in the c++ standard library,
5029 // doing better requires either some ugly hacks or breaking portability.
5030 static std::random_device seed_gen;
5031
5032 // Request 128 bits of entropy for initialization
5033 static std::seed_seq seed_sequence{seed_gen(), seed_gen(), seed_gen(),
5034 seed_gen()};
5035
5036 static std::mt19937 engine(seed_sequence);
5037
5038 std::string result;
5039 for (size_t i = 0; i < length; i++) {
5040 result += data[engine() % (sizeof(data) - 1)];
5041 }
5042 return result;
5043}
5044
5045inline std::string make_multipart_data_boundary() {
5046 return "--cpp-httplib-multipart-data-" + detail::random_string(16);

Callers 3

handle_requestMethod · 0.85
connect_with_proxyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected