コード例 #1
0
        public void Rijndael_EncryptionTest(string plainText)
        {
            //Arrange
            ICryptoEngine cryptoEngine = new RijndaelCryptoEngine();
            var           cipherText   = cryptoEngine.Encrypt(plainText, encryptionKey);

            //Act
            var salt = cryptoEngine.GetSaltBytes(cipherText).ToArray();
            var initialVectorBytes = cryptoEngine.GetInitialVectorBytes(cipherText).ToArray();
            var cipherAgain        = cryptoEngine.Encrypt(plainText, encryptionKey, salt, initialVectorBytes);

            //Assert
            Assert.AreEqual(cipherText, cipherAgain, "Encryption failed");
        }
コード例 #2
0
        public void Rijndael_EncryptionDecryptionTest(string plainText)
        {
            //Arrange
            ICryptoEngine cryptoEngine = new RijndaelCryptoEngine();

            //Act
            var cipherText = cryptoEngine.Encrypt(plainText, encryptionKey);
            var decipher   = cryptoEngine.Decrypt(cipherText, encryptionKey);

            //Assert
            Assert.AreEqual(plainText, decipher, "Encryption / Decryption failed");
        }