예제 #1
0
        private void btnDecode_Click(object sender, EventArgs e)
        {
            if (this.algorithm_number == null)
            {
                MessageBox.Show("Select the encoding/decoding algorithm.");
            }
            else
            {
                if (Validate_Phrase_Decode(this.richTextPhrase.Text, (int)this.algorithm_number))
                {
                    if (this.algorithm_number == 1)
                    {
                        string value = Microsoft.VisualBasic.Interaction.InputBox("Type the Value to proceed with the algorithm.", "Get Value", "", -1, -1);
                        if (ValidateVigenereValue(value.Trim()))
                        {
                            Vigenere_Substitution vs = new Vigenere_Substitution(this.richTextPhrase.Text.Trim(), value);
                            vs.Decode();
                            this.richTextPhrase.Text = vs.GetOutput_Phrase();
                        }
                        else
                        {
                            MessageBox.Show("WRONG!");
                        }
                    }
                    else if (this.algorithm_number == 5)
                    {
                        string keyword = Microsoft.VisualBasic.Interaction.InputBox("Type the Keyword to proceed with the algorithm.", "Get Keyword", "", -1, -1);
                        if (ValidateKeyword(keyword.Trim()))
                        {
                            Keyword kw = new Keyword(this.richTextPhrase.Text, keyword);
                            kw.Decode();
                            this.richTextPhrase.Text = kw.GetOutput_Phrase();
                        }
                        else
                        {
                            MessageBox.Show("WRONG!");
                        }
                    }
                    else
                    {
                        switch (this.algorithm_number)
                        {
                        case 2:
                            Binary_Code bc = new Binary_Code(this.richTextPhrase.Text);
                            bc.Decode();
                            this.richTextPhrase.Text = bc.GetOutput_Phrase();
                            break;

                        case 3:
                            Phone_Code pc = new Phone_Code(this.richTextPhrase.Text);
                            pc.Decode();
                            this.richTextPhrase.Text = pc.GetOutput_Phrase();
                            break;

                        case 4:
                            Transposition tr = new Transposition(this.richTextPhrase.Text);
                            tr.Decode();
                            this.richTextPhrase.Text = tr.GetOutput_Phrase();
                            break;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("INPUT ERROR");
                }
            }
        }
예제 #2
0
 private void btnDecode_Click(object sender, EventArgs e)
 {
     if (this.algorithm_number == null)
     {
         MessageBox.Show("Select the encoding/decoding algorithm.");
     }
     else
     {
         if (Validate_Phrase_Decode(this.richTextPhrase.Text, (int)this.algorithm_number))
         {
             if (this.algorithm_number == 1)
             {
                 string value = Microsoft.VisualBasic.Interaction.InputBox("Type the Value to proceed with the algorithm.", "Get Value", "", -1, -1);
                 if (ValidateVigenereValue(value.Trim()))
                 {
                     Vigenere_Substitution vs = new Vigenere_Substitution(this.richTextPhrase.Text.Trim(), value);
                     vs.Decode();
                     this.richTextPhrase.Text = vs.GetOutput_Phrase();
                 }
                 else
                 {
                     MessageBox.Show("WRONG!");
                 }
             }
             else if (this.algorithm_number == 5)
             {
                 string keyword = Microsoft.VisualBasic.Interaction.InputBox("Type the Keyword to proceed with the algorithm.", "Get Keyword", "", -1, -1);
                 if (ValidateKeyword(keyword.Trim()))
                 {
                     Keyword kw = new Keyword(this.richTextPhrase.Text, keyword);
                     kw.Decode();
                     this.richTextPhrase.Text = kw.GetOutput_Phrase();
                 }
                 else
                 {
                     MessageBox.Show("WRONG!");
                 }
             }
             else
             {
                 switch (this.algorithm_number)
                 {
                     case 2:
                         Binary_Code bc = new Binary_Code(this.richTextPhrase.Text);
                         bc.Decode();
                         this.richTextPhrase.Text = bc.GetOutput_Phrase();
                         break;
                     case 3:
                         Phone_Code pc = new Phone_Code(this.richTextPhrase.Text);
                         pc.Decode();
                         this.richTextPhrase.Text = pc.GetOutput_Phrase();
                         break;
                     case 4:
                         Transposition tr = new Transposition(this.richTextPhrase.Text);
                         tr.Decode();
                         this.richTextPhrase.Text = tr.GetOutput_Phrase();
                         break;
                 }
             }
         }
         else
         {
             MessageBox.Show("INPUT ERROR");
         }
     }
 }