refactor: get rid of unnecessary value assignments
This commit is contained in:
parent
27a73f94eb
commit
59605107c2
17
main_form.cs
17
main_form.cs
|
@ -74,11 +74,10 @@ namespace KRY_0x01_ng
|
|||
|
||||
bool check_key(TextBox tb_k, TextBox tb_pk, TextBox tb_na)
|
||||
{
|
||||
bool success = true;
|
||||
if (tb_k.Text.Length == 0)
|
||||
{
|
||||
MessageBox.Show("Empty key.", "Warning");
|
||||
return success = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
string str_to_check = String.Join("", tb_k.Text.ToUpper().Distinct());
|
||||
|
@ -86,19 +85,19 @@ namespace KRY_0x01_ng
|
|||
{
|
||||
/* because why not, 8 is still lame */
|
||||
MessageBox.Show($"The key is too short ({str_to_check.Length} characters).\nKey requirements: 9-25 unique alphabetic characters", "Error");
|
||||
return success = false;
|
||||
return false;
|
||||
}
|
||||
else if (str_to_check.Length > 25)
|
||||
{
|
||||
MessageBox.Show("The key is too long", "Warning");
|
||||
return success = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Match match = Regex.Match(str_to_check, @"\d|\s+");
|
||||
if (match.Success)
|
||||
{
|
||||
MessageBox.Show("Only alphabetic characters are allowed.\nCheck the key for numbers, symbols or tab whitespace and remove them before continuing.", "Error");
|
||||
return success = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
TextBox tb_pruned_k = tb_pk;
|
||||
|
@ -113,7 +112,7 @@ namespace KRY_0x01_ng
|
|||
string nualph_str = str_to_check + transientalph_str;
|
||||
tb_nualph.Text = nualph_str;
|
||||
nualphabet = nualph_str.ToCharArray();
|
||||
return success;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -231,8 +230,7 @@ namespace KRY_0x01_ng
|
|||
|
||||
void encrypt()
|
||||
{
|
||||
bool cool = check_key(textBox1, textBox2, textBox3);
|
||||
if (!cool)
|
||||
if (!check_key(textBox1, textBox2, textBox3))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -291,8 +289,7 @@ namespace KRY_0x01_ng
|
|||
|
||||
void decrypt()
|
||||
{
|
||||
bool cool = check_key(textBox8, textBox11, textBox10);
|
||||
if (!cool)
|
||||
if(!check_key(textBox8, textBox11, textBox10))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue