Untitled
unknown
plain_text
a year ago
532 B
11
Indexable
static std::string verification_code = generate_verification_code(10);
std::string generate_verification_code(size_t length) {
const char charset[] = "0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
std::default_random_engine rng(std::random_device{}());
std::uniform_int_distribution<> dist(0, sizeof(charset) - 2);
std::string code;
for (size_t i = 0; i < length; ++i) {
code += charset[dist(rng)];
}
return code;
}
Editor is loading...
Leave a Comment