Example #1
0
        private static void PerformEncryptOperation(out string plainText, out string cipherText, out int shift)
        {
            AppMessage("Welcome to encryption mode \nEnter message to encrypt");
            plainText = Console.ReadLine();
            shift     = 0; cipherText = string.Empty;
            if (plainText != "")
            {
                try
                {
                    AppMessage("Enter the shift");
                    shift = int.Parse(Console.ReadLine());

                    if (shift <= 26 && shift > 0)
                    {
                        AppMessage("Cipher is");

                        cipherText = new string(CaesarCipher.Encrypt(plainText, shift));
                        Console.WriteLine(cipherText);
                    }
                    else
                    {
                        ErrorMessage("Enter a number between 1 to 26");
                    }
                }
                catch (Exception e)
                {
                    ErrorMessage(e.Message);
                }
            }
            else
            {
                ErrorMessage("Invalid input");
            }
        }