This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacters.cs
80 lines (68 loc) · 2.45 KB
/
Characters.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
78
79
80
using System;
namespace PassGen
{
internal static class Characters
{
public const string AZCharList = "abcdefghijklmnopqrstuvwxyz";
public const string NumCharList = "0123456789";
public const string SpecialCharList = "`~!@#$%^&*()-_=+[{]}\\|;:\'\",<.>/?";
public const string AmbiguousCharList = "1LlioO0";
internal enum CharType
{
None = 0,
AZUpper = 1,
AZLower = 2,
Number = 3,
Special = 4
}
internal static CharType IdentifyCharType(char c)
{
string character = c.ToString();
Characters.CharType type = Characters.CharType.None;
if (Characters.AZCharList.ToUpper().Contains(character))
{
type = Characters.CharType.AZUpper;
}
else if (Characters.AZCharList.ToLower().Contains(character))
{
type = Characters.CharType.AZLower;
}
else if (Characters.NumCharList.Contains(character))
{
type = Characters.CharType.Number;
}
else if (Characters.SpecialCharList.Contains(character))
{
type = Characters.CharType.Special;
}
return type;
}
internal static char GetRandomChar(Characters.CharType returnType)
{
string charList = string.Empty;
switch (returnType)
{
case Characters.CharType.None:
charList += Characters.AZCharList.ToUpper();
charList += Characters.AZCharList.ToLower();
charList += Characters.NumCharList;
charList += Characters.SpecialCharList;
break;
case Characters.CharType.AZUpper:
charList += Characters.AZCharList.ToUpper();
break;
case Characters.CharType.AZLower:
charList += Characters.AZCharList.ToLower();
break;
case Characters.CharType.Number:
charList += Characters.NumCharList;
break;
case Characters.CharType.Special:
charList += Characters.SpecialCharList;
break;
}
int i = new Random().Next(0, charList.Length);
return charList[i];
}
}
}