| 25 | } |
| 26 | |
| 27 | std::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 | |
| 41 | Random::Random(): |
| 42 | randGen(std::random_device()()) |
no test coverage detected