예제 #1
0
        private string CheckThat(string key, string cipher)
        {
            string _result = SomeInstruments.DelSym(key);

            if (cipher == "Rail_Fence_ENG" || cipher == "Rail_Fence_ALL")
            {
                _result = SomeInstruments.DelAlp(_result);
                try
                {
                    int.Parse(_result);
                }
                catch (FormatException)
                {
                    _result = "";
                }
            }
            else if (cipher == "Playfair_ENG" || cipher == "Vigenere_ENG")
            {
                _result = SomeInstruments.ForText(_result);
            }
            else
            {
                _result = SomeInstruments.ForTextRUS(_result);
            }
            return(_result.ToLower());
        }
예제 #2
0
        static public string DeCipherRUS(string FileText, string key)
        {
            string text   = SomeInstruments.ForTextRUS(FileText.ToLower());
            string result = "";

            text.ToLower();
            // create a key
            int _priLenKey = key.Length;

            while (key.Length < text.Length)
            {
                key += alphabetRUS[(alphabetRUS.IndexOf(key[key.Length - _priLenKey]) + 1) % 26];
            }
            // create chiphertext
            int _index;

            for (int i = 0; i < text.Length; i++)
            {
                _index  = (alphabetRUS.IndexOf(text[i]) + 33 - alphabetRUS.IndexOf(key[i])) % 33;
                result += alphabetRUS[_index];
            }
            return(SomeInstruments.CreateTextRUS(FileText, result));
        }