Example #1
0
        static void Main(string[] args)
        {

            int a;
            try
            {
                
                do
                {
                    //do something
                    Console.WriteLine(@"Please,  type the number:
                        1.  To Morse code
                        2.  From Morse code
                        3.  To Morse code with key
                        4.  From Morse code with key
                        ");
                    try
                    {
                        a = int.Parse(Console.ReadLine());
                        Morse_matrix m1 = new Morse_matrix(0);
                        Morse_matrix m2 = new Morse_matrix(5);
                        switch (a)
                        {
                            case 1:
                                Str_matr_crypt("sos");
                                Console.WriteLine("");
                                break;
                            case 2:
                                Str_matr_decrypt(m1.string_crypt("sos"));
                                Console.WriteLine("");
                                break;
                            case 3:
                               
                                Str_matr_crypt_key("sos",5);
                                Console.WriteLine("");
                                break;
                            case 4:
                                Str_matr_decrypt_key(m2.string_crypt("sos"), 5);
                                Console.WriteLine("");
                                break;
                            default:
                                Console.WriteLine("Exit");
                                break;
                        }

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error");
                    }
                    finally
                    {

                    }

                    //end do something
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Press Spacebar to exit; press any key to continue");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                while (Console.ReadKey().Key != ConsoleKey.Spacebar);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
Example #2
0
        static void Str_matr_crypt_key(string word, int offset)
        {
            Morse_matrix m1 = new Morse_matrix(offset);
            string[] temp = m1.string_crypt(word);

            for (int i = 0; i < temp.Length; i++)
            {
                Console.Write(temp[i]);
            }
            Console.WriteLine("");
        }
Example #3
0
 static void Str_matr_decrypt_key(string[] code, int offset)
 {
     Morse_matrix m1 = new Morse_matrix(offset);
     Console.WriteLine(m1.string_decrypt(code));
 }
Example #4
0
 static void Str_matr_decrypt(string[] code)
 {
     Morse_matrix m1 = new Morse_matrix(0);
     Console.WriteLine(m1.string_decrypt(code));
 }