public void UnitCaesarDecipherWithSpace() { string text = "DEFGHI JKLMNOPQRSTUVWXYZ ABC"; string cipher = "ABCDEF GHIJKLMNOPQRSTUVW XYZ"; int shift = 3; CaesarCipher caesarCipher = new CaesarCipher(OldPlain, shift); Assert.That(cipher == caesarCipher.Decrypt(text)); }
public void UnitCaesarCipherDecipher() { string text = "Salut, je suis un message COOL!!!"; int shift = 8; CaesarCipher caesarCipher = new CaesarCipher(shift); string crypt = caesarCipher.Encrypt(text); System.Console.WriteLine(text + " != " + crypt); Assert.That(text != crypt); crypt = caesarCipher.Decrypt(crypt); System.Console.WriteLine(text + " == " + crypt); Assert.That(text == crypt); }
public bool ValidParameter() { try { if (sc == null) { sc = new CaesarCipher(textBoxTargeted.Text, (int)numericUpDownShift.Value); } else { sc.Plain = textBoxTargeted.Text; sc.Shift = (int)numericUpDownShift.Value; } numericUpDownShift.Value = sc.Shift; } catch(Exception e) { MessageBox.Show(e.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } return true; }
public void UnitRandomCaesarCipher() { Random random = new Random(ToolCipher.RandomSeed); for (int i = 0; i < 500; i++) { string text = ToolCipher.GenerateText(ToolCipher.AllChar, 500); int shift = random.Next(4, CaesarCipher.DEFAULT_PLAIN.Length - 1); System.Console.Out.WriteLine(shift); CaesarCipher caesarCipher = new CaesarCipher(shift); string textEncrypt = caesarCipher.Encrypt(text); System.Console.Out.WriteLine(text); System.Console.Out.WriteLine(textEncrypt); Assert.That(text != textEncrypt); string textDecrypt = caesarCipher.Decrypt(textEncrypt); System.Console.Out.WriteLine(text); System.Console.Out.WriteLine(textDecrypt); Assert.That(text == textDecrypt); } }