示例#1
0
        static void Main(string[] args)
        {
            EnigmaCore body = new EnigmaCore();         // ciało Enigmy

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("                               PROJEKT ENIGMA");
            Console.WriteLine("                             Opracowano: 03.2018");
            Console.WriteLine("                                Wersja: 1.14A");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("============================================================================");
            Console.WriteLine("Szczegóły odnośnie projektu:");
            Console.WriteLine("Obecna implementacja Enigmy(1.14A) składa się z trzech wirników(niem. Walzen),");
            Console.WriteLine("bez reflektora(niem. Umkehrwalze) i łącznicy kablowej(niem. Steckerbrett)");
            Console.WriteLine("warto mieć na uwadzę, że Enigma miała różne wersje w rzeczywistości. Jedną");
            Console.WriteLine("z najtrudniejszych do rozszyfrowania była Enigma dla Kriegsmarine z racji");
            Console.WriteLine("wprowadzenia tzw. kodu dziennego. Operatorzy wykorzystywali kod a następnie");
            Console.WriteLine("go niszczyli. Szczegóły i więcej informacji odnośnie Enigmy znajdziesz");
            Console.WriteLine("w linkach/literaturze, które zostały zamieszczone w dokumencie projektu");
            Console.WriteLine("*ENIGMA z WW2 miała słabość, która polegała na tym, że szyfrowana litera");
            Console.WriteLine("nigdy nie mogła być zaszyfrowana w samą siebie.");
            Console.WriteLine("============================================================================");
            Console.WriteLine("Menu wyboru: ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("1. Zaszyfruj wiadomość.");
            Console.WriteLine("2. Zaszyfruj wiadomość +tracking.");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("3. -");
            Console.WriteLine("4. -");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("5. Łącznica kablowa. (niedostępne)");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("6. Koniec programu.");
            Console.WriteLine("============================================================================");
            Console.WriteLine("kolorem zielonym oznaczono dostępne funkcje");
            int wybor = Convert.ToInt32(Console.ReadLine());

            // ---------------------------------->
            if (wybor == 1)
            {
                Console.WriteLine("Proszę ustalić klucz kodowania np. AGR - tylko duże litery!");
                string coding_key   = Console.ReadLine();
                char[] coding_table = new char[2];
                coding_table            = coding_key.ToCharArray();
                body.Rotor1_Position    = coding_table[0];
                body.Rotor2_Position    = coding_table[1];
                body.Rotor3_Position    = coding_table[2];
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\nUstalony klucz kodowania: \n => " + body.Rotor1_Position + body.Rotor2_Position + body.Rotor3_Position);
                Console.ForegroundColor = ConsoleColor.White;

                Console.WriteLine("\nPodaj tekst do zaszyfrowania(tylko duże litery!)");
                string tekst            = Console.ReadLine();
                int    rozmiar          = tekst.Length;
                char[] Chars_To_Encrypt = new char[rozmiar];
                Chars_To_Encrypt = tekst.ToCharArray();

                // Szyfrowanie
                // tutaj kod
                int i;
                for (i = 0; i < rozmiar; i++)
                {
                    char letter = Chars_To_Encrypt[i];
                    if ((int)letter >= 65 && (int)letter <= 90)
                    {
                        letter = body.Rotor1_Encryption(letter);

                        // gdy rotor2 może wykonać operacje
                        if (body.Rotor2_rotate == true)
                        {
                            letter = body.Rotor2_Encryption(letter);
                        }

                        if (body.Rotor3_rotate == true)
                        {
                            letter = body.Rotor3_Encryption(letter);
                        }

                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.Write(letter);
                    }
                    else
                    {
                        Console.Write(letter);
                    }
                    Console.ForegroundColor = ConsoleColor.White;
                }

                Console.WriteLine("\n\n\nSzyfrowanie wiadomości zakończone.");
            }
            // ---------------------------------->
            else if (wybor == 2)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("informacja o trybie TRACKING: ");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("każdą informację zatwierdzaj przyciskiem ENTER jeśli chcesz przejść dalej.");
                Console.WriteLine("<<kliknij enter>>");
                Console.ReadKey();
                Console.WriteLine("Proszę ustalić klucz kodowania np. AGR - tylko duże litery!");
                string coding_key   = Console.ReadLine();
                char[] coding_table = new char[2];
                coding_table            = coding_key.ToCharArray();
                body.Rotor1_Position    = coding_table[0];
                body.Rotor2_Position    = coding_table[1];
                body.Rotor3_Position    = coding_table[2];
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\nUstalony klucz kodowania: \n => " + body.Rotor1_Position + body.Rotor2_Position + body.Rotor3_Position);
                Console.ForegroundColor = ConsoleColor.White;

                Console.WriteLine("\nPodaj tekst do zaszyfrowania(tylko duże litery!)");
                string tekst            = Console.ReadLine();
                int    rozmiar          = tekst.Length;
                char[] Chars_To_Encrypt = new char[rozmiar];
                Chars_To_Encrypt = tekst.ToCharArray();

                // tablica zapisujaca zaszyfrowany kod
                char[] encrypted_array = new char[rozmiar];

                // Szyfrowanie
                // tutaj kod
                int i;
                for (i = 0; i < rozmiar; i++)
                {
                    char letter = Chars_To_Encrypt[i];
                    char copy   = letter;
                    if ((int)letter >= 65 && (int)letter <= 90)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("[input]: " + letter);
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.ReadKey();
                        letter = body.Rotor1_Encryption_tracked(letter);
                        Console.WriteLine("[rotor1]-exit: " + copy + "->" + letter);
                        copy = letter;

                        // gdy rotor2 może wykonać operacje
                        if (body.Rotor2_rotate == true)
                        {
                            Console.WriteLine("[rotor2]-in: " + letter);
                            Console.ReadKey();
                            letter = body.Rotor2_Encryption_tracked(letter);
                            Console.WriteLine("[rotor2]-exit: " + copy + "->" + letter);
                            Console.ReadKey();
                            copy = letter;
                        }

                        if (body.Rotor3_rotate == true)
                        {
                            Console.WriteLine("[rotor3]-in: " + letter);
                            Console.ReadKey();
                            letter = body.Rotor3_Encryption_tracked(letter);
                            Console.WriteLine("[rotor3]-exit: " + copy + "->" + letter);
                            Console.ReadKey();
                        }
                    }
                    else
                    {
                        Console.WriteLine("[whitespace]-ignore");
                        Console.ReadKey();
                    }

                    // tu tablice
                    encrypted_array[i] = letter;
                }
                Console.WriteLine("######################");
                Console.WriteLine("[track]-end of process.");
                string encrypted = new string(encrypted_array);

                Console.Write("[output]: ");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write(tekst);
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(" -> ");
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.Write(encrypted + "\n");
                Console.ForegroundColor = ConsoleColor.White;
                Console.ReadKey();
            }
            // ---------------------------------->
            else if (wybor == 3)
            {
                Console.WriteLine("Proszę ustalić klucz kodowania np. AGR - tylko duże litery!");
                string coding_key   = Console.ReadLine();
                char[] coding_table = new char[2];
                coding_table            = coding_key.ToCharArray();
                body.Rotor1_Position    = coding_table[0];
                body.Rotor2_Position    = coding_table[1];
                body.Rotor3_Position    = coding_table[2];
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\nUstalony klucz kodowania: \n => " + body.Rotor1_Position + body.Rotor2_Position + body.Rotor3_Position);
                Console.ForegroundColor = ConsoleColor.White;

                Console.WriteLine("\nPodaj tekst do odszyfrowania(tylko duże litery!)");
                string tekst            = Console.ReadLine();
                int    rozmiar          = tekst.Length;
                char[] Chars_To_Encrypt = new char[rozmiar];
                Chars_To_Encrypt = tekst.ToCharArray();

                // Szyfrowanie
                // tutaj kod
                int i;
                for (i = 0; i < rozmiar; i++)
                {
                    char letter = Chars_To_Encrypt[i];
                    if ((int)letter >= 65 && (int)letter <= 90)
                    {
                        letter = body.Rotor1_Decryption(letter);

                        // gdy rotor2 może wykonać operacje
                        if (body.Rotor2_rotate == true)
                        {
                            letter = body.Rotor2_Decryption(letter);
                        }

                        if (body.Rotor3_rotate == true)
                        {
                            letter = body.Rotor3_Decryption(letter);
                        }

                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.Write(letter);
                    }
                    else
                    {
                        Console.Write(letter);
                    }
                    Console.ForegroundColor = ConsoleColor.White;
                }

                Console.WriteLine("\n\n\nOdszyfrowanie wiadomości zakończone.");
            }
            // ---------------------------------->
            else if (wybor == 4)
            {
            }
            // ---------------------------------->
            else if (wybor == 5)
            {
            }
            // ---------------------------------->
            else if (wybor == 6)
            {
                Console.WriteLine("\nNaciśnij dowolny klawisz aby zakończyć...");
            }
            // ---------------------------------->
            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            EnigmaCore     body = new EnigmaCore();             // ciało Enigmy
            EnigmaAnalysis test = new EnigmaAnalysis();         // ciało Enigmy do testów

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("------------------------------");
            Console.WriteLine("------> ENIGMA - sol 3 <------");
            Console.WriteLine("-----> wersja ulepszona <-----");
            Console.WriteLine("--> Ostatni patch: 9.08.18 <--");
            Console.WriteLine("------------------------------\n");
            Console.ForegroundColor = ConsoleColor.White;

            for (int e = 0; e < 1;)
            {
                Console.WriteLine("///Panel wyboru:");
                Console.WriteLine("1. Zaszyfruj wiadomosc(widok slowny)");
                Console.WriteLine("2. Zaszyfruj wiadomosc(widok strzalkowy)");
                Console.WriteLine("3. Zbadaj działanie programu eni_sol3");
                Console.WriteLine("4. Koniec");

                string decyzja;
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("!> ");
                decyzja = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.White;

                if (decyzja == "3")
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("\nuwagi: ");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("- aby przejsc do kolejnego kroku działania, kliknij dowolny klawisz");
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.Write("!> ");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(" kolorem oznaczono elementy wywoływane przez funkcje z klasy");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write("!> ");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(" kolorem oznaczono elementy wywoływane przez główny kod enigmy");

                    Console.WriteLine("\nProszę ustalić klucz kodowania np. AGR \n(uwaga:tylko duże litery są akceptowalne)");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("!> ");
                    string coding_key = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    if (coding_key.Length < 3)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Podano za mało znaków!!! (wymagane: 3)");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("Podaj klucz kodowania jeszcze raz");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("!> ");
                        coding_key = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    char[] coding_table = new char[2];
                    coding_table         = coding_key.ToCharArray();
                    test.Rotor1_Position = coding_table[0];
                    test.Rotor2_Position = coding_table[1];
                    test.Rotor3_Position = coding_table[2];


                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine("\nUstalony klucz kodowania: \n => " + test.Rotor1_Position + test.Rotor2_Position + test.Rotor3_Position);
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine("\nPodaj tekst do zaszyfrowania(uwaga: tylko duże litery!)");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("!> ");
                    string tekst = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    int    rozmiar          = tekst.Length;
                    char[] Chars_To_Encrypt = new char[rozmiar];
                    Chars_To_Encrypt = tekst.ToCharArray();

                    char[] Encrypted_Text = new char[rozmiar];
                    char[] Main_Matrix    = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

                    // policz odległośc od A do podanej litery
                    int distance = test.Count_Distance(coding_table[0]);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("\n Odleglosć od znaku A = " + distance);
                    Console.WriteLine("<< kliknij dowolny przycisk aby przejśc dalej >>\n");
                    Console.ReadKey();

                    Console.ForegroundColor = ConsoleColor.White;

                    for (int x = 0; x < distance; x++)
                    {
                        Main_Matrix = body.Move_array(Main_Matrix);
                    }

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Stan tablicy po przesunięciu n-razy");
                    Console.ForegroundColor = ConsoleColor.White;
                    for (int x = 0; x < Main_Matrix.Length; x++)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(Main_Matrix[x] + " ");
                    }
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine("\n<< kliknij dowolny przycisk aby przejśc dalej >>\n");
                    Console.ReadKey();

                    int i;
                    for (i = 0; i < rozmiar; i++)
                    {
                        char letter = Chars_To_Encrypt[i];                          // bierzemy literkę

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.Write("!> ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(" Litera do zaszyfrowania: " + letter);
                        Console.ReadKey();

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.Write("!> ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(" Czy znak: " + letter + "(" + (int)letter + ") jest z przedzialu 65<>90?");
                        Console.ReadKey();

                        if (letter >= 65 && letter <= 90)                           // sprawdzamy czy się mieści w przedziale <>65<>90<>
                        {
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("-> TAK <-");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.ReadKey();

                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.Write("!> ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine(" Uruchom wirnik1");
                            Console.ReadKey();

                            test.Rotor1_Encryption();

                            if (test.Rotor2_rotate == true)
                            {
                                Console.ForegroundColor = ConsoleColor.Cyan;
                                Console.Write("!> ");
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine(" Uruchom wirnik2");
                                Console.ReadKey();

                                Main_Matrix = test.Rotor2_Encryption(Main_Matrix);
                            }

                            if (test.Rotor3_rotate == true)
                            {
                                Console.ForegroundColor = ConsoleColor.Cyan;
                                Console.Write("!> ");
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine(" Uruchom wirnik3");
                                Console.ReadKey();

                                Main_Matrix = test.Rotor3_Encryption(Main_Matrix);
                            }

                            int var = body.Return_RotorPositionNumber(letter);      // funkcja ktora przeszuka aktualna litere i zamieni ja na odpowiadajaca jej cyfre

                            // gdy var 25 , to jesli wezmiemy Main_Matrix[25+1]
                            // otrzymamy blad o przekroczeniu indeksu,
                            // gdy var bedzie 25 to nie dodamy +1 tylko odejmiemy -1
                            // bo Main_Matrix jest od 0-25 (26 liter)

                            char copy = letter;
                            if (var != 25)
                            {
                                letter = Main_Matrix[var + 1];                              // z tablicy Main_Matrix bierzemy element z pozycji var
                            }
                            else
                            {
                                letter = Main_Matrix[var - 1];
                            }

                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.Write("!> ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine(" Znak: " + copy + " zaszyfrowano znakiem: " + letter);
                            Console.ReadKey();

                            Main_Matrix = test.Move_array(Main_Matrix);             // przesuwamy pozycje znaków w tablicy
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("-> NIE <-");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.ReadKey();
                        }

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.Write("!> ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(" Wpisz znak: " + letter + " do tablicy zaszyfrowanej");
                        Console.ReadKey();

                        Encrypted_Text[i] = letter;                                 // wpisujemy znak do szyfrowanej tablicy
                    }

                    // wypisanie oryginalnego tekstu:
                    Console.Write("\n\n oryginalna wiadomosc -> ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    for (int w = 0; w < Chars_To_Encrypt.Length; w++)
                    {
                        Console.Write(Chars_To_Encrypt[w]);
                    }
                    Console.ForegroundColor = ConsoleColor.White;

                    // wypisanie zaszyfrowanego tekstu:
                    Console.Write("\n zaszyfrowana wiadomosc ->  ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    for (int w = 0; w < Encrypted_Text.Length; w++)
                    {
                        Console.Write(Encrypted_Text[w]);
                    }
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine();
                    Console.ReadKey();
                    Console.WriteLine();
                }
                else if (decyzja == "1")
                {
                    Console.WriteLine("\nProszę ustalić klucz kodowania np. AGR \n(uwaga:tylko duże litery są akceptowalne)");
                    Console.Write("!> ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    string coding_key = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    if (coding_key.Length < 3)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Podano za mało znaków!!! (wymagane: 3)");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("Podaj klucz kodowania jeszcze raz");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("!> ");
                        coding_key = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    char[] coding_table = new char[2];
                    coding_table         = coding_key.ToCharArray();
                    body.Rotor1_Position = coding_table[0];
                    body.Rotor2_Position = coding_table[1];
                    body.Rotor3_Position = coding_table[2];

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nUstalony klucz kodowania: \n => " + body.Rotor1_Position + body.Rotor2_Position + body.Rotor3_Position);
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine("\nPodaj tekst do zaszyfrowania(uwaga: tylko duże litery!)");
                    Console.Write("!> ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    string tekst = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    int    rozmiar          = tekst.Length;
                    char[] Chars_To_Encrypt = new char[rozmiar];
                    Chars_To_Encrypt = tekst.ToCharArray();

                    char[] Encrypted_Text = new char[rozmiar];
                    char[] Main_Matrix    = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

                    // policz odległośc od A do podanej litery
                    int distance = body.Count_Distance(coding_table[0]);

                    for (int x = 0; x < distance; x++)
                    {
                        Main_Matrix = body.Move_array(Main_Matrix);
                    }

                    // Przesuwanie TABLICY DZIALA!
                    // POPRAWIC RESZTE!!!!  ---> reszta działa
                    // zajrzenie do kodu: 28 V 18, i :( ....

                    int i;
                    for (i = 0; i < rozmiar; i++)
                    {
                        char letter = Chars_To_Encrypt[i];                          // bierzemy literkę
                                                                                    // sprawdzenie poboru literek:
                                                                                    // Console.Write(letter);
                        if (letter >= 65 && letter <= 90)                           // sprawdzamy czy się mieści w przedziale <>65<>90<>
                        {
                            body.Rotor1_Encryption();

                            if (body.Rotor2_rotate == true)
                            {
                                Main_Matrix = body.Rotor2_Encryption(Main_Matrix);
                            }

                            if (body.Rotor3_rotate == true)
                            {
                                Main_Matrix = body.Rotor3_Encryption(Main_Matrix);
                            }

                            int var = body.Return_RotorPositionNumber(letter);      // funkcja ktora przeszuka aktualna litere i zamieni ja na odpowiadajaca jej cyfre


                            if (var != 25)
                            {
                                letter = Main_Matrix[var + 1];                              // z tablicy Main_Matrix bierzemy element z pozycji var
                            }
                            else
                            {
                                letter = Main_Matrix[var - 1];
                            }

                            Main_Matrix = body.Move_array(Main_Matrix);             // przesuwamy pozycje znaków w tablicy
                        }

                        // jeżeli litera do zaszyfrowania była taka
                        // sama jak litera szyfrująca to przesuń
                        // o 1 dodatkowo
                        if (Chars_To_Encrypt[i] == letter)
                        {
                            int holder = (int)letter;
                            holder += 1;
                            letter  = (char)holder;
                        }

                        Encrypted_Text[i] = letter;                                 // wpisujemy znak do szyfrowanej tablicy
                    }

                    // wypisanie oryginalnego tekstu:
                    Console.Write("\n\n oryginalna wiadomosc -> ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    for (int w = 0; w < Chars_To_Encrypt.Length; w++)
                    {
                        Console.Write(Chars_To_Encrypt[w]);
                    }
                    Console.ForegroundColor = ConsoleColor.White;

                    // wypisanie zaszyfrowanego tekstu:
                    Console.Write("\n zaszyfrowana wiadomosc ->  ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    for (int w = 0; w < Encrypted_Text.Length; w++)
                    {
                        Console.Write(Encrypted_Text[w]);
                    }
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine();
                    Console.ReadKey();
                    Console.WriteLine();
                }
                else if (decyzja == "2")
                {
                    Console.WriteLine("\nProszę ustalić klucz kodowania np. AGR \n(uwaga:tylko duże litery są akceptowalne)");
                    Console.Write("!> ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    string coding_key = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    if (coding_key.Length < 3)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Podano za mało znaków!!! (wymagane: 3)");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("Podaj klucz kodowania jeszcze raz");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("!> ");
                        coding_key = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    char[] coding_table = new char[2];
                    coding_table            = coding_key.ToCharArray();
                    body.Rotor1_Position    = coding_table[0];
                    body.Rotor2_Position    = coding_table[1];
                    body.Rotor3_Position    = coding_table[2];
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nUstalony klucz kodowania: \n => " + body.Rotor1_Position + body.Rotor2_Position + body.Rotor3_Position);
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine("\nPodaj tekst do zaszyfrowania(uwaga: tylko duże litery!)");
                    Console.Write("!> ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    string tekst = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    int    rozmiar          = tekst.Length;
                    char[] Chars_To_Encrypt = new char[rozmiar];
                    Chars_To_Encrypt = tekst.ToCharArray();

                    char[] Encrypted_Text = new char[rozmiar];
                    char[] Main_Matrix    = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

                    // policz odległośc od A do podanej litery
                    int distance = body.Count_Distance(coding_table[0]);

                    for (int x = 0; x < distance; x++)
                    {
                        Main_Matrix = body.Move_array(Main_Matrix);
                    }

                    // Przesuwanie TABLICY DZIALA!
                    // POPRAWIC RESZTE!!!!  ---> reszta działa
                    // zajrzenie do kodu: 28 V 18, i :( ....

                    int i;
                    for (i = 0; i < rozmiar; i++)
                    {
                        char letter = Chars_To_Encrypt[i];                          // bierzemy literkę
                                                                                    // sprawdzenie poboru literek:
                                                                                    // Console.Write(letter);
                        if (letter >= 65 && letter <= 90)                           // sprawdzamy czy się mieści w przedziale <>65<>90<>
                        {
                            body.Rotor1_Encryption();

                            if (body.Rotor2_rotate == true)
                            {
                                Main_Matrix = body.Rotor2_Encryption(Main_Matrix);
                            }

                            if (body.Rotor3_rotate == true)
                            {
                                Main_Matrix = body.Rotor3_Encryption(Main_Matrix);
                            }

                            int var = body.Return_RotorPositionNumber(letter);      // funkcja ktora przeszuka aktualna litere i zamieni ja na odpowiadajaca jej cyfre


                            if (var != 25)
                            {
                                letter = Main_Matrix[var + 1];                              // z tablicy Main_Matrix bierzemy element z pozycji var
                            }
                            else
                            {
                                letter = Main_Matrix[var - 1];
                            }

                            Main_Matrix = body.Move_array(Main_Matrix);             // przesuwamy pozycje znaków w tablicy
                        }
                        Encrypted_Text[i] = letter;                                 // wpisujemy znak do szyfrowanej tablicy
                    }

                    for (int w = 0; w < Chars_To_Encrypt.Length; w++)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write("                 " + Chars_To_Encrypt[w]);
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("------>");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(Encrypted_Text[w]);
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("\n");
                    }

                    Console.WriteLine();
                    Console.ReadKey();
                    Console.WriteLine();
                }
                else if (decyzja == "4")
                {
                    Console.WriteLine();
                    Console.WriteLine("!> Naciśnij dowolny przycisk aby wyjsc...");
                    Console.ReadKey();
                    break;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Podano niewlasciwa opcje!");
                    Console.Write("Zamykanie programu");
                    Thread.Sleep(500);
                    Console.Write(".");
                    Thread.Sleep(600);
                    Console.Write(".");
                    Thread.Sleep(700);
                    Console.Write(".");
                    Thread.Sleep(800);
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                }
            }
        }