| 5021 | }; |
| 5022 | |
| 5023 | inline 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 | |
| 5045 | inline std::string make_multipart_data_boundary() { |
| 5046 | return "--cpp-httplib-multipart-data-" + detail::random_string(16); |
no outgoing calls
no test coverage detected