MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / alphanumeric_str

Method alphanumeric_str

include/Helpers/Random.cpp:27–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27std::string Random::alphanumeric_str(size_t len) {
28 std::string toRet;
29 char allowedChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
30 size_t allowedCharCount = sizeof(allowedChars) / sizeof(char);
31
32 // We use allowedCharCount - 2 as the right bound because the range is inclusive,
33 // and we dont want to include the implicit null terminator in the end of allowedChars
34 // as a possible character
35 for(size_t i = 0; i < len; i++)
36 toRet.push_back(allowedChars[Random::get().int_range<size_t>(0, allowedCharCount - 2)]);
37
38 return toRet;
39}
40
41Random::Random():
42 randGen(std::random_device()())

Callers 4

GlobalConfigMethod · 0.80
NetLibrary.cppFile · 0.80
register_clientMethod · 0.80

Calls 2

getFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected