public void SubsitutionCipher() { string text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string cipher = "DSJLPMECOGNWZ"; SubstitutionCipher sc = new SubstitutionCipher(text, cipher); string textEncrypt = sc.Encrypt(text); System.Console.Out.WriteLine(text); System.Console.Out.WriteLine(textEncrypt); Assert.That(text != textEncrypt); string textDecrypt = sc.Decrypt(textEncrypt); System.Console.Out.WriteLine(text); System.Console.Out.WriteLine(textDecrypt); Assert.That(text == textDecrypt); }
public void RandomSubstitutionCipherNonCaseSensitive() { for (int i = 0; i < 500; i++) { string text = ToolCipher.GenerateText(ToolCipher.AllChar, 500); string plain = ToolCipher.abc + ToolCipher.Number0At9; string cipher = ToolCipher.MixedString(plain, 10); SubstitutionCipher sc = new SubstitutionCipher(plain, cipher); string textEncrypt = sc.Encrypt(text); System.Console.Out.WriteLine(text); System.Console.Out.WriteLine(textEncrypt); Assert.That(text != textEncrypt); string textDecrypt = sc.Decrypt(textEncrypt); System.Console.Out.WriteLine(text); System.Console.Out.WriteLine(textDecrypt); Assert.That(text == textDecrypt); } }
public bool ValidParameter() { try { if (sc == null) { sc = new SubstitutionCipher(textBoxTargeted.Text, textBoxSubstituted.Text, checkBoxCaseSensitive.Checked); } else { sc.Plain = textBoxTargeted.Text; sc.Cipher = textBoxSubstituted.Text; sc.CaseSensitive = checkBoxCaseSensitive.Checked; } } catch(Exception e) { MessageBox.Show(e.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } return true; }
private void SubsitutionCipherChange() { _sc = new SubstitutionCipher(_plain, _plain.Substring(_shift) + _plain.Substring(0, _shift), false); }