Пример #1
0
        public void TestXorEncryptionDecryption()
        {
            XorObfuscation xorObfuscation = new XorObfuscation();

            byte[] plaintextBytes = new byte[] { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 };

            byte[] encryptedBytes =
                xorObfuscation.EncryptData_Method1(XorObfuscation.DefaultPassword, plaintextBytes, 0);

            byte[] decryptedBytes =
                xorObfuscation.DecryptData_Method1(XorObfuscation.DefaultPassword, encryptedBytes, 0);

            for (int i = 0; i < plaintextBytes.Length; i += 1)
            {
                Assert.AreNotEqual(plaintextBytes[i], encryptedBytes[i]);
                Assert.AreEqual(plaintextBytes[i], decryptedBytes[i]);
            }
        }
Пример #2
0
        public void TestXorEncryptionDecryption2()
        {
            XorObfuscation xorObfuscation = new XorObfuscation();

            byte[] mmsBytes      = new byte[] { 0x00, 0x00, 0xB0, 0x04 };
            byte   mmsByteOffset = 6;

            byte[] encryptedBytes =
                xorObfuscation.EncryptData_Method1(XorObfuscation.DefaultPassword, mmsBytes, mmsByteOffset);

            byte[] decryptedBytes =
                xorObfuscation.DecryptData_Method1(XorObfuscation.DefaultPassword, encryptedBytes, mmsByteOffset);

            for (int i = 0; i < mmsBytes.Length; i += 1)
            {
                Assert.AreNotEqual(mmsBytes[i], encryptedBytes[i]);
                Assert.AreEqual(mmsBytes[i], decryptedBytes[i]);
            }
        }