From 59605107c2294f84d4b60a593a6d7e71cd8218a4 Mon Sep 17 00:00:00 2001 From: citizen-VM Date: Mon, 24 Aug 2020 21:12:48 +0200 Subject: [PATCH] refactor: get rid of unnecessary value assignments --- main_form.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/main_form.cs b/main_form.cs index a3e7365..c645d9c 100644 --- a/main_form.cs +++ b/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; }