feat: add randomizeString
This commit is contained in:
@@ -12,3 +12,13 @@ std::string utils::getExePath()
|
|||||||
if (pos != std::string::npos) return path.substr(0, pos + 1);
|
if (pos != std::string::npos) return path.substr(0, pos + 1);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string utils::randomizeString(size_t length)
|
||||||
|
{
|
||||||
|
const char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
std::string result;
|
||||||
|
result.resize(length);
|
||||||
|
for (size_t i = 0; i < length; ++i)
|
||||||
|
result[i] = charset[rand() % (sizeof(charset) - 1)];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -5,4 +5,5 @@
|
|||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
std::string getExePath();
|
std::string getExePath();
|
||||||
|
std::string randomizeString(size_t length);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user