+ 1
Password Generator
How can we generate 8 character password including alphanumeric characters? And at least one from numbers, symbols, lower and upper characters must be in password.
2 odpowiedzi
+ 1
nice question, I got the basic 8 character password generator from community codes(it's in my code section password maker), but it needs to follow your atleast one of all types rule, so working on it.
0
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
static const char alphanum[] =
"0123456789"
"!@#$%^&*"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
static const char alphanum_Num[] = "0123456789";
static const char alphanum_Sym[] =
"!@#$%^&*"
;
static const char alphanum_Upp[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const char alphanum_Low[] =
"abcdefghijklmnopqrstuvwxyz";
int size = sizeof(alphanum) - 1;
int main()
{
//password length
int n;
char a;
srand(time(0));
cout << alphanum_Num [rand() % 9];
cout << alphanum_Sym [rand() % 7];
cout << alphanum_Upp [rand() % 25];
cout << alphanum_Low [rand() % 25];
for (int i = 0; i < 4; i++)
{
cout << alphanum[rand() % size];
}
return 0;
}