Untitled
Anonymous
plain_text
06/30/2024 11:07 AM
712 B
18
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