Exemplo n.º 1
0
        private List <string> GetUniqueWords(string[] potencialyWords, List <char> mostFrequentLetters, string[] WORDS) //TODO Debug
        {
            WORDSWORDS.Clear();                                                                                         //TODO Debug


            var randomRange = Polibian.GetRandomRange(potencialyWords.Length);
            var resultWords = new List <string>();

            for (int i = 0; i < randomRange.Length; i++)
            {
                if (mostFrequentLetters.Count == 0)
                {
                    break;
                }

                bool flage = false;
                var  item  = potencialyWords[randomRange[i]];
                for (int j = 0; j < item.Length; j++)
                {
                    if (mostFrequentLetters.Contains(item[j]))
                    {
                        flage = true;
                        mostFrequentLetters.Remove(item[j]);
                    }
                }
                if (flage)
                {
                    resultWords.Add(item);
                    WORDSWORDS.Add(WORDS[randomRange[i]]);
                }
            }

            return(resultWords);
        }
Exemplo n.º 2
0
        public bool IsInputValid()
        {
            if (!String.IsNullOrEmpty(txtKey.Text))
            {
                var lines = txtKey.Text.Split('\r', '\n');

                foreach (var item in lines)
                {
                    if (item.Length != 0)
                    {
                        if (!Polibian.IsStringValid(item))
                        {
                            MessageBox.Show("Допустимы буквы русского алфавита и символы .,!?;\"-'");
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else
            {
                MessageBox.Show("Введите ключ");
                return(false);
            }
        }
Exemplo n.º 3
0
 private void btnDecrypt_Click(object sender, RoutedEventArgs e)
 {
     if (IsInputValid())
     {
         var polibian = new Polibian(txtKey.Text);
         txtOutputInformation.Text = polibian.DecryptText(txtInputInformation.Text);
     }
 }
Exemplo n.º 4
0
        private void LoadLink_Click(object sender, RoutedEventArgs e)
        {
            string key = GetFileText();

            if (Polibian.IsStringValid(key))
            {
                txtKey.Text = key;
            }
            else
            {
                MessageBox.Show("Ключ поврежден");
            }
        }
Exemplo n.º 5
0
 private void GenerationLink_Click(object sender, RoutedEventArgs e)
 {
     txtKey.Text = Polibian.GetKey();
 }