private string Encrypt() { EncMatrice = Cell.EncryptionMatrice(KeyToEnc, FractionatedMessage); string alphabeticalOrderKey = String.Concat(KeyToEnc.OrderBy(c => c)); string encryptedMessage = String.Empty; for (int i = 0; i < alphabeticalOrderKey.Length; i++) { var matrice = EncMatrice.Where(x => x.KeyLetter == alphabeticalOrderKey[i]).ToList(); foreach (var p in matrice) { encryptedMessage += p.letter.ToString(); } encryptedMessage += " "; } return(encryptedMessage); }
private void textBox6_TextChanged(object sender, EventArgs e) { string alph = alphabet.Replace("0123456789", ""); textBox6.Text = textBox6.Text.ToUpper(); if (!IsInAlphabet(textBox6.Text, alph)) { textBox6.Text = textBox6.Text.Remove(textBox6.Text.Length - 1, 1); } if (textBox6.Text.Length > 1) { if (KeyToEnc != null && KeyToEnc.Contains(textBox6.Text.Replace(KeyToEnc, ""))) { textBox6.Text = KeyToEnc; } } KeyToEnc = textBox6.Text; textBox6.SelectionStart = textBox6.Text.Length; textBox6.SelectionLength = 0; }