public void DecodeTest() { var c = new GronsfeldCipher(); Assert.AreEqual("EXALTATION", new String(c.Decode("HYEMYDUMPS", new byte[] { 3, 1, 4, 1, 5 }))); Assert.AreEqual("I love challenges!", new String(c.Decode("M%muxi%dncpqftiix\"", new byte[] { 4, 5, 1, 6, 2 }))); Assert.AreEqual("Test input.", new String(c.Decode("Uix!&kotvx3", new byte[] { 1, 4, 5, 8, 6, 2, 1, 4 }))); }
public void SymetryTest() { byte[] key = new byte[] { 3, 2, 5, 7, 1, 4, 0 }; string msg = "Hello World!"; var c = new GronsfeldCipher(); Assert.AreEqual(msg, new String(c.Decode(new String(c.Encode(msg, key)), key))); CollectionAssert.AreEqual(msg.ToCharArray(), c.Decode(new String(c.Encode(msg, key)), key)); }
public void UserSuppliedAlphabet() { string alphabet = "ABCD0123.!, "; byte[] key = new byte[] { 1, 2 }; string msg = "AAAA01"; // You can only use elements from the alphabet var c = new GronsfeldCipher(alphabet); Assert.AreEqual(msg, new String(c.Decode(new String(c.Encode(msg, key)), key))); CollectionAssert.AreEqual(msg.ToCharArray(), c.Decode(new String(c.Encode(msg, key)), key)); }