示例#1
0
        public void CryptoRC2_128Bit_FixedIV_Test()
        {
            //Arrange
            byte[] key = { 158, 23, 64, 96, 57, 225, 36, 85, 250, 23, 45, 94, 12, 36, 67, 170 };
            byte[] iv  = { 63, 208, 159, 46, 37, 77, 1, 59 };

            CryptoSymmetric crypto = new CryptoRC2(key);

            crypto.SetIV(iv);
            string originalMessage  = "I love cryptography and RC2 with a 128-bits key";
            string encryptedMessage = crypto.Encrypt(originalMessage);

            //Act
            string decryptedMessage = crypto.Decrypt(encryptedMessage);

            //Assert
            Assert.AreNotEqual(originalMessage, encryptedMessage);
            Assert.AreEqual(originalMessage, decryptedMessage);
        }
示例#2
0
        public void CryptoRC2_40Bit_FixedIV_Test()
        {
            //Arrange
            byte[] key = { 45, 6, 251, 89, 16 };
            byte[] iv  = { 63, 208, 159, 46, 37, 77, 1, 59 };

            CryptoSymmetric crypto = new CryptoRC2(key);

            crypto.SetIV(iv);
            string originalMessage  = "I love cryptography and RC2 with a 40-bits key";
            string encryptedMessage = crypto.Encrypt(originalMessage);

            //Act
            string decryptedMessage = crypto.Decrypt(encryptedMessage);

            //Assert
            Assert.AreNotEqual(originalMessage, encryptedMessage);
            Assert.AreEqual(originalMessage, decryptedMessage);
        }