feat: added correct message padding
This commit is contained in:
parent
66a8a00b13
commit
5ad4cbc7c3
37
main_form.cs
37
main_form.cs
|
@ -49,9 +49,9 @@ namespace KRY_0x01_ng
|
||||||
{
|
{
|
||||||
second_char = 'Q';
|
second_char = 'Q';
|
||||||
}
|
}
|
||||||
else if ((i == str.Length || str[i] == first_char) && (first_char != 'W'))
|
else if ((i == str.Length || str[i] == first_char) && (first_char != 'Z'))
|
||||||
{
|
{
|
||||||
second_char = 'W';
|
second_char = 'Z';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,10 @@ namespace KRY_0x01_ng
|
||||||
padded_str += first_char;
|
padded_str += first_char;
|
||||||
padded_str += second_char;
|
padded_str += second_char;
|
||||||
}
|
}
|
||||||
|
if (padded_str.Length % 2 != 0)
|
||||||
|
{
|
||||||
|
padded_str = pad(padded_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return padded_str;
|
return padded_str;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +78,7 @@ namespace KRY_0x01_ng
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string str_to_check = str_to_check = String.Join("", tb_k.Text.ToUpper().Distinct());
|
string str_to_check = String.Join("", tb_k.Text.ToUpper().Distinct());
|
||||||
if (str_to_check.Length < 9)
|
if (str_to_check.Length < 9)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"The key is too short ({str_to_check.Length} characters).\nKey requirements: 9-25 unique alphabetic characters", "Error");
|
MessageBox.Show($"The key is too short ({str_to_check.Length} characters).\nKey requirements: 9-25 unique alphabetic characters", "Error");
|
||||||
|
@ -93,7 +97,15 @@ namespace KRY_0x01_ng
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TextBox tb_pruned_k = textBox2;
|
TextBox tb_pruned_k = textBox2;
|
||||||
|
TextBox tb_nualph = textBox3;
|
||||||
tb_pruned_k.Text = str_to_check;
|
tb_pruned_k.Text = str_to_check;
|
||||||
|
nualphabet = alphabet.Except(str_to_check.ToArray()).ToArray();
|
||||||
|
string nualph_str = "";
|
||||||
|
for (int i = 0; i < nualphabet.Length; i++)
|
||||||
|
{
|
||||||
|
nualph_str += nualphabet[i];
|
||||||
|
}
|
||||||
|
tb_nualph.Text = str_to_check + nualph_str;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,23 +129,8 @@ namespace KRY_0x01_ng
|
||||||
}
|
}
|
||||||
void prep_message(TextBox tb_m)
|
void prep_message(TextBox tb_m)
|
||||||
{
|
{
|
||||||
string msg = tb_m.Text;
|
string msg = pad(tb_m.Text);
|
||||||
if (msg.Length % 2 != 0)
|
textBox6.Text = msg;
|
||||||
{
|
|
||||||
if (! msg.EndsWith("X"))
|
|
||||||
{
|
|
||||||
msg += "X";
|
|
||||||
}
|
|
||||||
else if (! msg.EndsWith("Q"))
|
|
||||||
{
|
|
||||||
msg += "Q";
|
|
||||||
}
|
|
||||||
else if (! msg.EndsWith("Z"))
|
|
||||||
{
|
|
||||||
msg += "Z";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
textBox6.Text = pad(msg);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue