diff --git a/KRY-0x01-ng.csproj b/KRY-0x01-ng.csproj index c1d98bc..74a09e8 100644 --- a/KRY-0x01-ng.csproj +++ b/KRY-0x01-ng.csproj @@ -46,16 +46,16 @@ - + Form - - Form1.cs + + main_form.cs - - Form1.cs + + main_form.cs ResXFileCodeGenerator diff --git a/main_form.Designer.cs b/main_form.Designer.cs index 5bdf7af..027c2ec 100644 --- a/main_form.Designer.cs +++ b/main_form.Designer.cs @@ -60,7 +60,7 @@ this.textBox2.Name = "textBox2"; this.textBox2.ReadOnly = true; this.textBox2.Size = new System.Drawing.Size(313, 20); - this.textBox2.TabIndex = 1; + this.textBox2.TabIndex = 100; // // label1 // @@ -104,14 +104,14 @@ this.textBox3.Name = "textBox3"; this.textBox3.ReadOnly = true; this.textBox3.Size = new System.Drawing.Size(313, 20); - this.textBox3.TabIndex = 5; + this.textBox3.TabIndex = 500; // // textBox4 // this.textBox4.Location = new System.Drawing.Point(12, 281); this.textBox4.Name = "textBox4"; this.textBox4.Size = new System.Drawing.Size(313, 20); - this.textBox4.TabIndex = 7; + this.textBox4.TabIndex = 2; // // label4 // @@ -178,18 +178,20 @@ this.button1.Location = new System.Drawing.Point(12, 307); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 15; + this.button1.TabIndex = 3; this.button1.Text = "encrypt"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(12, 210); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 16; + this.button2.TabIndex = 1; this.button2.Text = "check key"; this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); // // main_form // diff --git a/main_form.cs b/main_form.cs index 9d5c5bb..6178cbd 100644 --- a/main_form.cs +++ b/main_form.cs @@ -5,6 +5,7 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; @@ -16,5 +17,94 @@ namespace KRY_0x01_ng { InitializeComponent(); } + + char[,] arrayTable = new char[5, 5]; + char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVXYZ".ToCharArray(); // no W + char[] nualphabet = new char[25]; + + + + public string prune_input(TextBox tb) + { + string str = tb.Text.ToUpper(); + string alpha_str = Regex.Replace(str, " ", "MEZERABRO"); + alpha_str = alpha_str.Replace("[^A-Z]+", ""); + return alpha_str.Replace("W", "V"); + } + public string restore_order(string str) + { + string alpha_str = Regex.Replace(str, "MEZERABRO", " "); + return alpha_str; + } + + public string pad(string str) + { + string padded_str = ""; + if (str.Length > 0) + { + int i = 0; + while (i < str.Length) + { + char first_char = str[i]; + i++; + char second_char; + if ((i == str.Length || str[i] == first_char) && (first_char != 'X')) + { + second_char = 'X'; + } + else if ((i == str.Length || str[i] == first_char) && (first_char != 'Q')) + { + second_char = 'Q'; + } + else if ((i == str.Length || str[i] == first_char) && (first_char != 'W')) + { + second_char = 'W'; + } + else + { + second_char = str[i]; + i++; + } + padded_str += first_char; + padded_str += second_char; + } + } + return padded_str; + } + + + void check_key() + { + return; + } + + void check_message(TextBox tb_m) + { + string msg = pad(tb_m.Text); + return; + } + + + void encrypt() + { + string cryptmessage = ""; + string m_text = prune_input(textBox4); + return; + } + + + + private void button1_Click(object sender, EventArgs e) + { + /* encrypt button */ + check_message(textBox4); + encrypt(); + } + + private void button2_Click(object sender, EventArgs e) + { + /* check key button */ + check_key(); + } } }