Esempio n. 1
0
        public void EncryptTest()
        {
            byte[]     key    = null;                      // TODO: Initialize to an appropriate value
            Arc4Cipher target = new Arc4Cipher(key, true); // TODO: Initialize to an appropriate value

            byte[] input    = null;                        // TODO: Initialize to an appropriate value
            byte[] expected = null;                        // TODO: Initialize to an appropriate value
            byte[] actual;
            actual = target.Encrypt(input);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 2
0
        public void Encrypt_DischargeFirstBytes_False1()
        {
            const string key                = "Key";
            const string plainText          = "Plaintext";
            var          encoding           = Encoding.ASCII;
            var          cipher             = new Arc4Cipher(encoding.GetBytes(key), false);
            var          expectedCipherText = new byte[] { 0xBB, 0xF3, 0x16, 0xE8, 0xD9, 0x40, 0xAF, 0x0A, 0xD3 };

            var actualCipherText = cipher.Encrypt(encoding.GetBytes(plainText));

            Assert.IsNotNull(actualCipherText);
            Assert.IsTrue(expectedCipherText.IsEqualTo(actualCipherText));
        }
Esempio n. 3
0
        public void Encrypt_DischargeFirstBytes_False2()
        {
            const string key                = "Wiki";
            const string plainText          = "pedia";
            var          encoding           = Encoding.ASCII;
            var          cipher             = new Arc4Cipher(encoding.GetBytes(key), false);
            var          expectedCipherText = new byte[] { 0x10, 0X21, 0xBF, 0x04, 0x20 };

            var actualCipherText = cipher.Encrypt(encoding.GetBytes(plainText));

            Assert.IsNotNull(actualCipherText);
            Assert.IsTrue(expectedCipherText.IsEqualTo(actualCipherText));
        }
Esempio n. 4
0
        public void Encrypt_InputAndOffsetAndLength()
        {
            const string key                = "Wiki";
            const string plainText          = "NOpediaNO";
            var          encoding           = Encoding.ASCII;
            var          cipher             = new Arc4Cipher(encoding.GetBytes(key), false);
            var          plainTextBytes     = encoding.GetBytes(plainText);
            var          expectedCipherText = new byte[] { 0x10, 0X21, 0xBF, 0x04, 0x20 };

            var actualCipherText = cipher.Encrypt(plainTextBytes, 2, plainTextBytes.Length - 4);

            Assert.IsNotNull(actualCipherText);
            Assert.IsTrue(expectedCipherText.IsEqualTo(actualCipherText));

            Assert.IsTrue(plainTextBytes.IsEqualTo(encoding.GetBytes(plainText)));
        }
Esempio n. 5
0
        public void Encrypt_DischargeFirstBytes_False1()
        {
            const string key                = "Key";
            const string plainText          = "Plaintext";
            var          encoding           = Encoding.ASCII;
            var          cipher             = new Arc4Cipher(encoding.GetBytes(key), false);
            var          expectedCipherText = new byte[] { 0xBB, 0xF3, 0x16, 0xE8, 0xD9, 0x40, 0xAF, 0x0A, 0xD3 };

            var actualCipherText = cipher.Encrypt(encoding.GetBytes(plainText));

            Assert.IsNotNull(actualCipherText);
            Assert.AreEqual(expectedCipherText.Length, actualCipherText.Length);
            Assert.AreEqual(expectedCipherText[0], actualCipherText[0]);
            Assert.AreEqual(expectedCipherText[1], actualCipherText[1]);
            Assert.AreEqual(expectedCipherText[2], actualCipherText[2]);
            Assert.AreEqual(expectedCipherText[3], actualCipherText[3]);
            Assert.AreEqual(expectedCipherText[4], actualCipherText[4]);
            Assert.AreEqual(expectedCipherText[5], actualCipherText[5]);
            Assert.AreEqual(expectedCipherText[6], actualCipherText[6]);
            Assert.AreEqual(expectedCipherText[7], actualCipherText[7]);
            Assert.AreEqual(expectedCipherText[8], actualCipherText[8]);
        }