示例#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();
        }
示例#2
0
        private void buttonDecode_Click(object sender, EventArgs e)
        {
            var language    = cbLanguage.SelectedItem.ToString();
            var coder       = new Coder(language);
            var encodedText = rtbInput.Text;
            var key         = cbPossibleKeys.SelectedItem.ToString();
            var decodedText = coder.Decode(encodedText, key);

            rtbOutput.Text = decodedText;
        }