public string Decipher(string message, int key)
        {
            Dictionary <char, string> tabulaRecta = TableFunctions.MakeTable(charLine);
            string output = "";

            message = message.ToUpper();
            message = String.Concat(message.Where(c => !Char.IsWhiteSpace(c)));

            try
            {
                while (output.Length < message.Length)
                {
                    for (int i = 0; i < message.Length; i++)
                    {
                        int    charPos = TableFunctions.GetCharPos(message[i], charLine[key]);
                        string temp    = tabulaRecta['A'];
                        output += temp[charPos];
                    }
                }
            }
            catch (Exception e)
            {
                MultiCipherCLI.InvalidChar();
            }
            return(output);
        }
        public string Encipher(string message, int key)
        {
            Dictionary <char, string> tabulaRecta = TableFunctions.MakeTable(charLine);
            string output = "";

            message = message.ToUpper();
            message = String.Concat(message.Where(c => !Char.IsWhiteSpace(c)));


            try
            {
                while (output.Length < message.Length)
                {
                    for (int i = 0; i < message.Length; i++)
                    {
                        foreach (KeyValuePair <char, string> charX in tabulaRecta)
                        {
                            if (charLine[key] == charX.Key)
                            {
                                int charPos = TableFunctions.GetCharPos(message[i], 'A');
                                output += charX.Value[charPos];
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MultiCipherCLI.InvalidChar();
            }
            return(output);
        }
示例#3
0
        public string Encipher(string message, string key)
        {
            Dictionary <char, string> tabulaRecta = TableFunctions.MakeTable(extCharLine);
            string output = "";

            try
            {
                while (output.Length < message.Length)
                {
                    for (int i = 0; i < message.Length; i++)
                    {
                        int k = i;
                        if (k > key.Length - 2)
                        {
                            k = (k % key.Length);
                        }
                        foreach (KeyValuePair <char, string> charX in tabulaRecta)
                        {
                            if (key[k] == charX.Key)
                            {
                                int charPos = TableFunctions.GetExtCharPos(message[i], 'A');
                                output += charX.Value[charPos];
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MultiCipherCLI.InvalidChar();
            }
            return(output);
        }
示例#4
0
        public string Decipher(string message, string key)
        {
            Dictionary <char, string> tabulaRecta = TableFunctions.MakeTable(extCharLine);
            string output = "";

            try
            {
                while (output.Length < message.Length)
                {
                    for (int i = 0; i < message.Length; i++)
                    {
                        int k = i;
                        if (k > key.Length - 2)
                        {
                            k = (k % key.Length);
                        }
                        int    charPos = TableFunctions.GetExtCharPos(message[i], key[k]);
                        string temp    = tabulaRecta['A'];
                        output += temp[charPos];
                    }
                }
            }
            catch (Exception e)
            {
                MultiCipherCLI.InvalidChar();
            }
            return(output);
        }
        public static int GetExtCharPos(char input, char keyChar)
        {
            int charPos = 0;

            Dictionary <char, string> tabulaRecta = MakeTable(MakeExtCharLine());
            string alphaCheck = tabulaRecta[keyChar];

            try
            {
                for (int i = 0; i < alphaCheck.Length; i++)
                {
                    if (input == alphaCheck[i])
                    {
                        charPos = i;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                MultiCipherCLI.InvalidChar();
            }
            return(charPos);
        }