/// Translational Logic for Vigenere is here. public string VigenereTranslate(string input) { if (string.IsNullOrWhiteSpace(input)) { return(string.Empty); // no harm, no foul. } var map = RowPattern; var cleaned = input.ToUpper().Replace(" ", "").Replace("'", "").Replace(",", "").Replace(".", "").Replace("!", "").Replace("-", "").Replace("?", ""); var phr = Paraphrase.ToUpper(); int phrase_offset = 0; var matrix = VigenereMatrix; var buffer = new StringBuilder(); for (var pos = 0; pos < cleaned.Length; pos++) { var row_char = cleaned[pos]; var col_char = phr[phrase_offset++]; var posX = map.IndexOf(row_char); var posY = map.IndexOf(col_char); var letter = matrix[posX][posY].ToString(); buffer.Append(letter); if (phrase_offset >= phr.Length) { phrase_offset = 0; } } return(buffer.ToString()); }
private void SaveParaphrase_Action() { if (string.IsNullOrWhiteSpace(Paraphrase) || Paraphrase.Length < 6) { MessageBox.Show("Your Paraphrase should be at least 6 characters, letters only."); return; } if (!Paraphrase.All(ltr => "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(ltr.ToString().ToUpper()))) { MessageBox.Show("Your Paraphrase should be letters only."); return; } Paraphrase = Paraphrase.ToUpper(); ParaphraseInfinityBreadcrumb = Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase + Paraphrase; TriggerTranslate(); }