public void TestAesCbcWithIntegrityRoundTrip() { var privateKey = AesCbcWithIntegrity.GenerateKey(); var mySecretText = "This is my secret"; var mySecretBytes = Encoding.UTF8.GetBytes(mySecretText); var cipherText = AesCbcWithIntegrity.Encrypt(mySecretBytes, privateKey); Assert.False(AesCbcWithIntegrity.ConstantTimeEq(mySecretBytes, cipherText.GetCipherText())); var decryptedBytes = AesCbcWithIntegrity.Decrypt(cipherText, privateKey); var decryptedText = Encoding.UTF8.GetString(decryptedBytes); Assert.True(mySecretText == decryptedText, string.Format("Expect {0} but got {1}", mySecretText, decryptedText)); }