Esempio n. 1
0
        public void TestRoundtripWithIV()
        {
            var tests = new TestCase[]
            {
                new TestCase("ABC",
                             new byte[] { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
                             "The quick brown fox jumps over the lazy dog"),
                new TestCase("spam",
                             new byte[] { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
                             "A returning noise skips into the arcade"),
                new TestCase("arcfour",
                             new byte[] { 0xff, 0xf0, 0xef, 0xe0, 0xdf, 0xd0, 0xcf, 0xc0 },
                             "The postage postulates a chaos"),
            };

            foreach (var tc in tests)
            {
                var key  = tc.Key;
                var data = tc.Output;
                var iv   = tc.IV;

                var ctxt = Spritz.Encrypt(data, key, iv);
                var ptxt = Spritz.Decrypt(ctxt, key, iv);

                CollectionAssert.AreEqual(data, ptxt);
            }
        }
Esempio n. 2
0
        public void TestRoundtrip()
        {
            var tests = new TestCase[]
            {
                new TestCase("I am a key",
                             "Hello, World!"),
                new TestCase("ABC",
                             "The quick brown fox jumps over the lazy dog"),
                new TestCase("spam",
                             "A returning noise skips into the arcade"),
                new TestCase("arcfour",
                             "The postage postulates a chaos"),
                new TestCase("lizard",
                             "The glue bounces"),
            };

            foreach (var tc in tests)
            {
                var key  = tc.Key;
                var data = tc.Output;

                var ctxt = Spritz.Encrypt(data, key);
                var ptxt = Spritz.Decrypt(ctxt, key);

                Console.WriteLine("Plaintext: " + ByteArrayToString(data));
                Console.WriteLine("Key: " + ByteArrayToString(key));
                Console.WriteLine("Ciphertext: " + ByteArrayToString(ctxt));
                Console.WriteLine();
                CollectionAssert.AreEqual(data, ptxt);
            }
        }