Exemple #1
0
        private void buttonDecodeAll_Click(object sender, EventArgs e)
        {
            var encodedText        = rtbInput.Text;
            var language           = cbLanguage.SelectedItem.ToString();
            var breaker            = new VigenereBreaker(language);
            var coder              = new Coder(language);
            var possibleKeyLengths = breaker.GetPossibleKeyLengths(encodedText);
            var possibleKeys       = new List <string>();
            var sb = new StringBuilder();

            foreach (var item in possibleKeyLengths)
            {
                possibleKeys.AddRange(breaker.GetPossibleKeys(item, encodedText));
            }

            for (int i = 0; i < possibleKeys.Count; i++)
            {
                var key         = possibleKeys[i];
                var decodedText = coder.Decode(encodedText, key);

                sb.Append($"{i + 1}. Ключ: {key}\n{decodedText}\n\n");
            }

            rtbOutput.Text = sb.ToString();
        }
Exemple #2
0
        private void buttonAnalysis_Click(object sender, EventArgs e)
        {
            cbPossibleKeyLengths.Items.Clear();
            rtbOutput.Clear();

            var text               = rtbInput.Text;
            var language           = cbLanguage.SelectedItem.ToString();
            var breaker            = new VigenereBreaker(language);
            var possibleKeyLengths = breaker.GetPossibleKeyLengths(text);

            foreach (var item in possibleKeyLengths)
            {
                cbPossibleKeyLengths.Items.Add(item);
            }

            cbPossibleKeyLengths.SelectedItem = cbPossibleKeyLengths.Items[0];
        }