Skip to content

Commit 2024ab3

Browse files
author
Milli
committed
Added error handling for invalid keys and IVs
1 parent 2a7a0be commit 2024ab3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Main.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,17 @@ private void RunClicked(object sender, EventArgs e)
8585
}
8686
else
8787
{
88-
a.Key = Convert.FromBase64String(textBox_Key.Text);
89-
a.IV = Convert.FromBase64String(textBox_IV.Text);
88+
try
89+
{
90+
a.Key = Convert.FromBase64String(textBox_Key.Text);
91+
a.IV = Convert.FromBase64String(textBox_IV.Text);
92+
}
93+
catch (CryptographicException)
94+
{
95+
label_Note.Text = "Key or IV invalid, new key and IV generated.";
96+
textBox_IV.Text = Convert.ToBase64String(a.IV);
97+
textBox_Key.Text = Convert.ToBase64String(a.Key);
98+
}
9099
}
91100

92101
output = Encoder.AES(output, a.Key, a.IV, encode);

MuEncode.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<UseWindowsForms>true</UseWindowsForms>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<ApplicationIcon>greenMu.ico</ApplicationIcon>
10+
<GenerateDocumentationFile>False</GenerateDocumentationFile>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

0 commit comments

Comments
 (0)