Пример #1
0
        public List <ZamiennikowyKeys> GetListOfKeys()
        {
            List <ZamiennikowyKeys> list = new List <ZamiennikowyKeys>();
            FileStream   fs = new FileStream(Location, FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);
            string       line;

            while ((line = sr.ReadLine()) != null)
            {
                ZamiennikowyKeys zamiennikowyKey = new ZamiennikowyKeys(line.Split(Separator));
                list.Add(zamiennikowyKey);
            }

            return(list);
        }
Пример #2
0
        public string Encryption(string explicitText, string keyName)
        {
            List <ZamiennikowyKeys> list = GetListOfKeys();
            ZamiennikowyKeys        key  = list.Find(fkey => fkey.keyName == keyName);

            nonpublicText = "";
            foreach (char letter in explicitText)
            {
                if (Char.IsLetter(letter))
                {
                    if (Char.IsLower(letter))
                    {
                        if (latinLowerAlphabet.IndexOf(PolishToLatinLetter(letter)) == -1)
                        {
                            nonpublicText += letter;
                        }
                        else
                        {
                            nonpublicText += Char.ToLower(key.key[latinLowerAlphabet.IndexOf(PolishToLatinLetter(letter))]);
                        }
                    }
                    else
                    {
                        if (latinAlphabet.IndexOf(PolishToLatinLetter(letter)) == -1)
                        {
                            nonpublicText += letter;
                        }
                        else
                        {
                            nonpublicText += key.key[latinAlphabet.IndexOf(PolishToLatinLetter(letter))];
                        }
                    }
                }
                else
                {
                    nonpublicText += letter;
                }
            }
            return(nonpublicText);
        }