Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine();

            //Getting the key from user
            string key = "";

            do
            {
                ColorfulConsole.Write("Input the key: ", ConsoleColor.White);
                key = ColorfulConsole.ReadLine(ConsoleColor.Red);
            }while (String.IsNullOrWhiteSpace(key) || String.IsNullOrEmpty(key) || key == "0");

            Console.WriteLine();

            //Getting the text from user
            ColorfulConsole.Write("Input the text to be encrypted: ", ConsoleColor.White);
            string input = ColorfulConsole.ReadLine(ConsoleColor.Yellow);

            Console.WriteLine();

            //Encrypting the text
            var encryptor = new StringEncryptor(key);

            encryptor.Encrypt(input);

            //Showing the results
            encryptor.PrintTable();
            Console.WriteLine();
            ColorfulConsole.Write($"Encrypted text: ", ConsoleColor.White);
            ColorfulConsole.Write(encryptor.EncryptedText, ConsoleColor.Green);

            Console.WriteLine();
            Console.WriteLine();
        }
Beispiel #2
0
        public void PrintTable()
        {
            if (!IsTableReady)
            {
                Console.WriteLine("Calculation not completed!");
                return;
            }

            int length = firstLine.Length;
            const ConsoleColor rowNameColor = ConsoleColor.Magenta;
            const ConsoleColor valuesColor  = ConsoleColor.White;

            ColorfulConsole.Write("Input:\t", rowNameColor);
            for (int i = 0; i < length; i++)
            {
                ColorfulConsole.Write(firstLine[i] + "\t", ConsoleColor.Yellow);
            }
            Console.WriteLine();

            ColorfulConsole.Write("2-nd:\t", rowNameColor);
            for (int i = 0; i < length; i++)
            {
                ColorfulConsole.Write(secondLine[i] + "\t", valuesColor);
            }
            Console.WriteLine();

            ColorfulConsole.Write("Key:\t", rowNameColor);
            for (int i = 0; i < length; i++)
            {
                ColorfulConsole.Write(this.Key + "\t", ConsoleColor.Red);
            }
            Console.WriteLine();

            ColorfulConsole.Write("4-th:\t", rowNameColor);
            for (int i = 0; i < length; i++)
            {
                ColorfulConsole.Write(fourthLine[i] + "\t", valuesColor);
            }
            Console.WriteLine();

            ColorfulConsole.Write("Result:\t", rowNameColor);
            for (int i = 0; i < length; i++)
            {
                ColorfulConsole.Write(resultLine[i] + "\t", ConsoleColor.Green);
            }
            Console.WriteLine();
        }