forked from HidekiHiguchi/passwordGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.c
More file actions
76 lines (57 loc) · 961 Bytes
/
generator.c
File metadata and controls
76 lines (57 loc) · 961 Bytes
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
//testte
//tabela ascii (a..z) = 97..122
//(A..Z) = 65..90
//(0..9) = 48..57
//Obrigado
int main()
{
int pw[59];
int j=0, x=0;
for (j = 97; j <= 122; j++)
{
pw[x] = j;
x++;
}
for (j = 48; j<= 58; j++)
{
pw[x] = j;
x++;
}
for(j =65; j<90; j++)
{
pw[x] = j;
x++;
}
int pwlen = 0;
char upper; //seting non-uppercase as default
printf("Enter Password length: ");
scanf("%d", &pwlen);
printf("Deseja usar letras maiusculas: y/n?: ");
scanf(" %c",&upper);
printf("\n\nYour password generated is: ");
if(upper == 'n')
{
int count, i;
srand ( time(NULL) );
for( count = 0; count <= pwlen -1 ; count++)
{
i = rand() % 36;
printf("%c",pw[i]);
}
printf("\n");
}
else
{
int count, i;
srand ( time(NULL) );
for( count = 0; count <= pwlen ; count++)
{
i = rand() % 59;
printf("%c",pw[i]);
}
printf("\n");
}
printf("\n\n");
return(0);
}