Example #1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     progressBar1.Increment(4);
     if (progressBar1.Value == 100)
     {
         timer1.Stop();
         progressBar1.Value = 0;
         label7.Text        = "";
         if (encrypting)
         {
             try {
                 //if(Convert.ToInt32(textBox3.Text) < 0)
                 //    throw new Exception();
                 textBox5.Text = Caesar.encrypt(textBox1.Text, Convert.ToInt32(textBox3.Text));
                 encrypting    = false;
             } catch (Exception ex) {
                 MessageBox.Show("Ju lutemi mbushini te gjitha kutite e enkriptimit.\nQelesi duhet te jete nje numer i plote.");
             }
         }
         else if (decrypting)
         {
             try {
                 //if(Convert.ToInt32(textBox4.Text) < 0)
                 //    throw new Exception();
                 textBox6.Text = Caesar.decrypt(textBox2.Text, Convert.ToInt32(textBox4.Text));
                 decrypting    = false;
             } catch (Exception ex) {
                 MessageBox.Show("Ju lutemi mbushini te gjitha kutite e dekriptimit.\nQelesi duhet te jete nje numer i plote.");
             }
         }
         else if (sendingToDecrypt)
         {
             try {
                 if (textBox5.Text == null || textBox3.Text == null)
                 {
                     throw new Exception();
                 }
                 textBox2.Text    = textBox5.Text;
                 textBox4.Text    = textBox3.Text;
                 sendingToDecrypt = false;
             } catch (Exception ex) {
                 MessageBox.Show("Nuk ka te dhena per te derguar.");
             }
         }
         else if (sendingToEncrypt)
         {
             try {
                 if (textBox5.Text == null || textBox3.Text == null)
                 {
                     throw new Exception();
                 }
                 textBox1.Text    = textBox6.Text;
                 textBox3.Text    = textBox4.Text;
                 sendingToEncrypt = false;
             } catch (Exception ex) {
                 MessageBox.Show("Nuk ka te dhena per te derguar.");
             }
         }
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            Caesar caesar = new Caesar(15);

            Console.WriteLine("Caesar Cipher - Function Kata");

            Console.WriteLine("Welche Zeichenkette möchten Sie verschlüsseln?");

            var input     = Console.ReadLine();
            var encrypted = caesar.GetEncryptedString(input);

            Console.WriteLine("Encrypted: " + encrypted);
            Console.WriteLine("Decrypted: " + caesar.GetDecryptedString(encrypted));

            Console.ReadKey();
        }