private static void TestSymmetricCryptoAPI() { string messageToEncrypt1 = "Alice knows Bob's secret."; string messageToEncrypt2 = "Alice knows Bob's favorite color."; SymmetricAlgorithm aes = new AesCryptoServiceProvider(); aes.KeySize = 256; byte[] key = aes.Key; // The symmetric key used for encrypt - decrypt - same for both messages byte[] encryptedMessage1 = SymmetricCrypto.EncryptWithAes(messageToEncrypt1, aes); byte[] iv1 = aes.IV; string decryptedMessage1 = SymmetricCrypto.DecryptMessageWithAES(key, iv1, encryptedMessage1); aes = new AesCryptoServiceProvider(); aes.KeySize = 256; aes.Key = key; byte[] encryptedMessage2 = SymmetricCrypto.EncryptWithAes(messageToEncrypt2, aes); byte[] iv2 = aes.IV; string decryptedMessage2 = SymmetricCrypto.DecryptMessageWithAES(key, iv2, encryptedMessage2); }