Exemplo n.º 1
0
 public void EncodeTest()
 {
     var c = new GronsfeldCipher();
     Assert.AreEqual("HYEMYDUMPS", new String(c.Encode("EXALTATION", new byte[] { 3, 1, 4, 1, 5 })));
     Assert.AreEqual("M%muxi%dncpqftiix\"", new String(c.Encode("I love challenges!", new byte[] { 4, 5, 1, 6, 2 })));
     Assert.AreEqual("Uix!&kotvx3", new String(c.Encode("Test input.", new byte[] { 1, 4, 5, 8, 6, 2, 1, 4 })));
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
        public void Gronsfeld()
        {
            GronsfeldCipher cipher = new GronsfeldCipher();

            int[] key = { 3, 2, 6 };

            const string plaintext  = "Geheimnis";
            const string ciphertext = "Jgnhksqky";

            Assert.AreEqual(ciphertext, cipher.Encrypt(plaintext, key));
            Assert.AreEqual(plaintext, cipher.Decrypt(ciphertext, key));
        }