| 72 | } |
| 73 | |
| 74 | std::string StringUtils::RandomString(size_t len) { |
| 75 | const std::string charset = "abcdefghijklmnopqrstuvwxyz" |
| 76 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 77 | "0123456789" |
| 78 | "!@#$%^&*()-_=+[]{}|;:,.<>?"; |
| 79 | std::vector<uint8_t> buffer(len); |
| 80 | if(!RAND_bytes(buffer.data(), (int)len)) |
| 81 | return {}; |
| 82 | std::string result{}; |
| 83 | result.reserve(len); |
| 84 | for(size_t i = 0; i < len; ++i) |
| 85 | result += charset[buffer[i] % charset.size()]; |
| 86 | return result; |
| 87 | } |
| 88 | |
| 89 | std::string StringUtils::WithSeperators(const std::string &str, const std::string &seperator, uint32_t groupSize) { |
| 90 | std::vector<std::string> chunks{}; |