21 lines
524 B
C++
21 lines
524 B
C++
#include "randomstringgenerator.h"
|
|
|
|
#include <string>
|
|
#include <random>
|
|
|
|
std::u8string RandomStringGenerator::getU8string(uint16_t length)
|
|
{
|
|
static const std::string characters = "abcdefghijklmnopqrstuvwxyz";
|
|
std::random_device rd;
|
|
std::mt19937 generator(rd());
|
|
std::uniform_int_distribution<> distribution(0, characters.size() - 1);
|
|
|
|
std::u8string randomString;
|
|
for (size_t i = 0; i < length; ++i)
|
|
{
|
|
randomString += characters[distribution(generator)];
|
|
}
|
|
|
|
return randomString;
|
|
}
|