Example #1
0
 /// <summary>
 ///     The main.
 /// </summary>
 /// <param name="args">
 ///     The args.
 /// </param>
 internal static void Main(string[] args)
 {
     var caesarCipher = new CaesarCipher(Alphabets.English26, -22);
     Console.WriteLine("Please make a choice: E to encrypt, D to decrypt and X for exit");
     while (true)
     {
         var key = Console.ReadKey();
         Console.WriteLine();
         switch (key.KeyChar)
         {
             case 'e':
                 Console.WriteLine("Please enter a message to encrypt: ");
                 var message = Console.ReadLine();
                 var cipherText = caesarCipher.Encrypt(message);
                 Console.WriteLine("Ciphertext: {0}", cipherText);
                 continue;
             case 'd':
                 Console.WriteLine("Please enter a message to decrypt: ");
                 var ciphertext = Console.ReadLine();
                 var plaintext = caesarCipher.Decrypt(ciphertext);
                 Console.WriteLine("Message: {0}", plaintext);
                 continue;
             case 'x':
                 return;
         }
     }
 }
Example #2
0
 public override void EncryptTest()
 {
     var cipher = new CaesarCipher(Alphabets.English26, Shift);
     var ciphertext = cipher.Encrypt(Message);
     Assert.AreEqual(Ciphertext, ciphertext);
 }
Example #3
0
 public override void DecryptTest()
 {
     var cipher = new CaesarCipher(Alphabets.English26, Shift);
     var plaintext = cipher.Decrypt(Ciphertext);
     Assert.AreEqual(Message, plaintext);
 }