-
Notifications
You must be signed in to change notification settings - Fork 0
/
PasswordGenerator.c
57 lines (49 loc) · 1.19 KB
/
PasswordGenerator.c
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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
void RandomPasswordGenerator(int n){
int i=0;
int randomizer=0;
srand((unsigned int)(time(NULL)));
char numbers[]="0123456789";
char letters[]="abcdefghijklmnopqrstuvwxyz";
char LETTERS[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char symbols[]="!@#$%^&*?";
char password[n];
randomizer=rand()%4;
for (i=0; i<n; i++){
if (randomizer==1){
password[i]=numbers[rand()%10];
randomizer=rand()%4;
printf("%c", password[i]);
}
else if (randomizer==2){
password[i]=symbols[rand()%8];
randomizer=rand()%4;
printf("%c", password[i]);
}
else if (randomizer==3){
password[i]=letters[rand()%26];
randomizer=rand()%4;
printf("%c", password[i]);
}
else {
password[i]=LETTERS[rand()%26];
randomizer=rand()%4;
printf("%c", password[i]);
}
}
}
int main(){
int n;
do{
printf("Give n : ");
scanf("%d", &n);
}
while (n<15);
RandomPasswordGenerator(n);
printf("\n");
system ("Pause");
return 0;
}