-
Notifications
You must be signed in to change notification settings - Fork 0
/
Generator.cs
77 lines (73 loc) · 2.08 KB
/
Generator.cs
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
76
77
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace Password_Generator
{
class Generator
{
Random rnd;
private List<string> Numbers;
private List<string> Symbols;
private List<string> AlphaUpper;
private List<string> AlphaLower;
public string Password;
public Generator()
{
rnd = new Random(DateTime.Now.Millisecond);
Numbers = new List<string>() {"0123456789"};
AlphaUpper = new List<string>() {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
AlphaLower = new List<string>() { "abcdefghijklmnopqrstuvwxyz"};
Symbols = new List<string>() {"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ "};
}
public string PasswordGenerate(int size, bool num, bool sym, bool UpA, bool LowA)
{
Password = null;
string buf = null;
if (UpA == true)
{
foreach (string s in AlphaUpper)
{
buf += s;
}
}
if (LowA == true)
{
foreach (string s in AlphaLower)
{
buf += s;
}
}
if (num == true)
{
foreach (string s in Numbers)
{
buf += s;
}
}
if (sym == true)
{
foreach (string s in Symbols)
{
buf += s;
}
}
for (int i = 0; i < size; i++)
{
Password += buf[rnd.Next(buf.Length)];
}
return Password;
}
public string UserPasswordGenerate(int size, string symbols)
{
Password = null;
for (int i = 0; i < size; i++)
{
Password += symbols[rnd.Next(symbols.Length)];
}
return Password;
}
}
}