MCPcopy Create free account
hub / github.com/MeisApps/pcbu-desktop / RandomString

Method RandomString

common/src/utils/StringUtils.cpp:74–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74std::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
89std::string StringUtils::WithSeperators(const std::string &str, const std::string &seperator, uint32_t groupSize) {
90 std::vector<std::string> chunks{};

Callers

nothing calls this directly

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected