-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.h
60 lines (47 loc) · 938 Bytes
/
generator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef GENERATOR_H
#define GENERATOR_H
#include <random>
#include <algorithm>
#include "random.h"
using namespace std;
string passwordGenerator(int n)
{
string password = "";
const char alphabets[27] = {"abcdefghijklmnopqrstuvwxyz"};
const char nums[11] = {"1234567890"};
const char symbols[11] = {"@#$%^&!+=?"};
int prt1 = n/3;
int prt2 = n/3;
int prt3 = n - (2*(n/3));
int rand_num;
for(int i = 0; i < prt3; i++)
{
rand_num = makeRandom(0, 25);
if(i <= (prt1/3))
{
char x = alphabets[rand_num];
x-=32;
password += x;
}
else
{
char x = alphabets[rand_num];
password += x;
}
}
for(int i = 0; i < prt2; i++)
{
rand_num = makeRandom(0, 9);
char x = nums[rand_num];
password += x;
}
for(int i = 0; i < prt1; i++)
{
rand_num = makeRandom(0, 9);
char x = symbols[rand_num];
password += x;
}
random_shuffle(password.begin(), password.end());
return password;
}
#endif