You can easily create a password generator in C++ with the following simple method.
How to create the Password Generator in C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <iostream>
#include <string>
#include <algorithm>
#include <random>
std::string generate_password(int length = 16) {
std::string seed = string("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + string("0123456789") + string("!@#$%^&*()_+=-{}[]\\|:;<>,.?/");
std::string password_string = seed;
std::shuffle(password_string.begin(), password_string.end(), std::mt19937{std::random_device{}()});
return password_string.substr(0, length);
}
int main() {
std::cout << generate_password() << std::endl;
std::cout << generate_password(28) << std::endl;
return 0;
}
|