Skip to content

Commit c5f3e92

Browse files
committed
Версия 1.1
1 parent 8697c8d commit c5f3e92

File tree

4 files changed

+140
-31
lines changed

4 files changed

+140
-31
lines changed

Form1.Designer.cs

Lines changed: 33 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Form1.cs

Lines changed: 103 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,139 @@ namespace PassGen
44
{
55
public partial class MainForm : Form
66
{
7-
static readonly string AlphabetCapital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
8-
static readonly string AlphabetLower = "abcdefghijklmnopqrstuvwxyz";
9-
static readonly string AlphabetNumber = "0123456789";
10-
static readonly string AlphabetLine = "-_";
11-
static readonly string AlphabetSpecial = "`~!@#$%^&*()+={}[]\\|:;\"\'<>,.?/";
12-
static readonly string AlphabetSpace = " ";
7+
string AlphabetCapital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
8+
string AlphabetLower = "abcdefghijklmnopqrstuvwxyz";
9+
const string AlphabetNumber = "0123456789";
10+
const string AlphabetLine = "-_";
11+
string AlphabetSpecial = "`~!@#$%^&*()+={}[]\\|:;\"\'<>,.?/";
1312
string Password = string.Empty;
1413
int PasswordLength = 12;
1514

1615
private void GeneratePassword()
1716
{
17+
if (CheckBoxReadable.Checked)
18+
{
19+
AlphabetCapital = "ABCDEFGHJKPQRSTUVWXYZ";
20+
AlphabetLower = "abcdefghjkpqrstuvwxyz";
21+
AlphabetSpecial = "!@#$%&+=?";
22+
}
23+
1824
string alphabet = string.Empty;
1925
if (CheckBoxCapital.Checked) { alphabet += AlphabetCapital; }
2026
if (CheckBoxLower.Checked) { alphabet += AlphabetLower; }
2127
if (CheckBoxNumber.Checked) { alphabet += AlphabetNumber; }
2228
if (CheckBoxLine.Checked) { alphabet += AlphabetLine; }
2329
if (CheckBoxSpecial.Checked) { alphabet += AlphabetSpecial; }
24-
if (CheckBoxSpace.Checked) { alphabet += AlphabetSpace; }
2530

2631
int alphabetSize = alphabet.Length;
2732
if (alphabetSize == 0)
33+
{
34+
FieldPassword.Text = string.Empty;
2835
return;
36+
}
2937

3038
Password = string.Empty;
3139
for (int i = 0; i < PasswordLength; i++)
3240
{
3341
int randomNumber = RandomNumberGenerator.GetInt32(0, alphabetSize);
34-
char randomSymbol = alphabet[randomNumber];
42+
string randomSymbol = alphabet[randomNumber].ToString();
3543
Password += randomSymbol;
3644
}
3745

46+
if (CheckBoxForce.Checked)
47+
{
48+
ForceAddition();
49+
}
50+
3851
FieldPassword.Text = Password;
3952
}
4053

54+
private void ForceAddition()
55+
{
56+
int checkedCount = 0;
57+
if (CheckBoxCapital.Checked) { checkedCount++; }
58+
if (CheckBoxLower.Checked) { checkedCount++; }
59+
if (CheckBoxNumber.Checked) { checkedCount++; }
60+
if (CheckBoxLine.Checked) { checkedCount++; }
61+
if (CheckBoxSpecial.Checked) { checkedCount++; }
62+
63+
if (checkedCount > PasswordLength)
64+
{
65+
Password = string.Empty;
66+
return;
67+
}
68+
69+
string positions = string.Empty;
70+
int position = 0;
71+
int randomPosition;
72+
for (int i = 0; i < checkedCount; i++)
73+
{
74+
do
75+
{
76+
randomPosition = RandomNumberGenerator.GetInt32(0, PasswordLength);
77+
}
78+
while (positions.Contains(randomPosition.ToString()));
79+
positions += randomPosition;
80+
}
81+
if (CheckBoxCapital.Checked)
82+
{
83+
int randomNumber = RandomNumberGenerator.GetInt32(0, AlphabetCapital.Length);
84+
string randomSymbol = AlphabetCapital[randomNumber].ToString();
85+
Password = Password.Remove(Convert.ToInt32(positions[position].ToString()), 1);
86+
Password = Password.Insert(Convert.ToInt32(positions[position].ToString()), randomSymbol);
87+
position++;
88+
}
89+
if (CheckBoxLower.Checked)
90+
{
91+
int randomNumber = RandomNumberGenerator.GetInt32(0, AlphabetLower.Length);
92+
string randomSymbol = AlphabetLower[randomNumber].ToString();
93+
Password = Password.Remove(Convert.ToInt32(positions[position].ToString()), 1);
94+
Password = Password.Insert(Convert.ToInt32(positions[position].ToString()), randomSymbol);
95+
position++;
96+
}
97+
if (CheckBoxNumber.Checked)
98+
{
99+
int randomNumber = RandomNumberGenerator.GetInt32(0, AlphabetNumber.Length);
100+
string randomSymbol = AlphabetNumber[randomNumber].ToString();
101+
Password = Password.Remove(Convert.ToInt32(positions[position].ToString()), 1);
102+
Password = Password.Insert(Convert.ToInt32(positions[position].ToString()), randomSymbol);
103+
position++;
104+
}
105+
if (CheckBoxLine.Checked)
106+
{
107+
int randomNumber = RandomNumberGenerator.GetInt32(0, AlphabetLine.Length);
108+
string randomSymbol = AlphabetLine[randomNumber].ToString();
109+
Password = Password.Remove(Convert.ToInt32(positions[position].ToString()), 1);
110+
Password = Password.Insert(Convert.ToInt32(positions[position].ToString()), randomSymbol);
111+
position++;
112+
}
113+
if (CheckBoxSpecial.Checked)
114+
{
115+
int randomNumber = RandomNumberGenerator.GetInt32(0, AlphabetSpecial.Length);
116+
string randomSymbol = AlphabetSpecial[randomNumber].ToString();
117+
Password = Password.Remove(Convert.ToInt32(positions[position].ToString()), 1);
118+
Password = Password.Insert(Convert.ToInt32(positions[position].ToString()), randomSymbol);
119+
position++;
120+
}
121+
}
122+
41123
public MainForm()
42124
{
43125
InitializeComponent();
44126
GeneratePassword();
127+
ToolTip toolTip = new();
128+
toolTip.SetToolTip(CheckBoxLine, "Ñèìâîëû \"-\" è \"_\"");
129+
toolTip.SetToolTip(CheckBoxSpecial, "Ðàçíûå ñïåöèàëüíûå ñèìâîëû");
130+
toolTip.SetToolTip(CheckBoxNumber, "Âêëþ÷åíèå öèôð â ïàðîëü");
131+
toolTip.SetToolTip(CheckBoxLower, "Âêëþ÷åíèå ñòðî÷íûõ áóêâ â ïàðîëü (a-z)");
132+
toolTip.SetToolTip(CheckBoxCapital, "Âêëþ÷åíèå çàãëàâíûõ áóêâ â ïàðîëü (A-Z)");
133+
toolTip.SetToolTip(CheckBoxForce, " ïàðîëå áóäåò íå ìåíåå îäíîãî ñèìâîëà èç êàæäîé îòìå÷åííîé êàòåãîðèè");
134+
toolTip.SetToolTip(CheckBoxReadable, "Â ïàðîëå íå áóäóò ïîïàäàòüñÿ ñèìâîëû, êîòîðûå ëåãêî ñïóòàòü (íàïðèìåð, 0 è O èëè l è I)");
135+
toolTip.SetToolTip(ButtonCopy, "Ñêîïèðîâàòü ïàðîëü â áóôåð îáìåíà");
136+
toolTip.SetToolTip(SizeBar, "Äâèãàÿ âëåâî è âïðàâî, ìîæíî èçìåíèòü äëèíó ïàðîëÿ");
137+
toolTip.SetToolTip(LabelScrollValue, "Òåêóùàÿ äëèíà ïàðîëÿ");
138+
toolTip.SetToolTip(ButtonGen, "Ñîçäàòü íîâûé ïàðîëü");
139+
toolTip.SetToolTip(FieldPassword, "Ñîçäàííûå ïàðîëè. Åñëè ïîëå ïóñòîå, çíà÷èò âûáðàííûå íàñòðîéêè íå ïîçâîëÿþò ñîçäàòü åãî");
45140
}
46141

47142
private void ButtonGen_Click(object sender, EventArgs e)

PassGen.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<StartupObject>PassGen.Program</StartupObject>
1010
<ApplicationIcon>Resources\Icon.ico</ApplicationIcon>
1111
<Title>OliveWizrd PassGen</Title>
12-
<Version>$(VersionPrefix) 1.0.0</Version>
12+
<Version>$(VersionPrefix) 1.1.0</Version>
1313
<Authors>OliveWizard</Authors>
1414
<Description>Генератор паролей</Description>
1515
<PackageIcon>Logo.png</PackageIcon>

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@
66
+ Цифры
77
+ Тире и нижнее подчеркивание
88
+ Специальные символы
9-
+ Пробел
9+
10+
Дополнительно можно отметить обязательность появления хотя бы одного символа из отмеченной категории и исключить похожие друг на друга или сложночитаемые символы.
1011

1112
## Системные требования
1213
Основная версия программы (PassGen.exe) требует Windows 10 (версию 1607) или новее и [.Net 7](https://dotnet.microsoft.com/en-us/download) (любой вариант).
1314

1415
Автономная версия программы (PassGen.7z) не требует .Net 7.
1516

16-
### [Скачать программу](https://github.com/OneCodeUnit/PassGen/releases/latest)
17-
18-
## В планах
19-
+ Исключение похожих символов
20-
+ Обязательное присутствие символа из группы
21-
+ Сохранение настроек
22-
+ Кириллические пароли
17+
### [Скачать программу](https://github.com/OneCodeUnit/PassGen/releases/latest)

0 commit comments

Comments
 (0)