public void RsaHelperBytesShouldSucceed() { var directory = TestContext.DeploymentDirectory; var helper = new RsaHelper(Path.Combine(directory, "TestCertificate.pfx"), CertificatePassword); var aes = new AesManaged(); aes.GenerateIV(); aes.GenerateKey(); var originalKey = aes.Key; var originalIv = aes.IV; var encryptedKeyBytes = helper.RsaEncryptBytes(aes.Key); var encryptedIvBytes = helper.RsaEncryptBytes(aes.IV); encryptedIvBytes.Should().NotBeNull("IV failed to encrypt"); encryptedKeyBytes.Should().NotBeNull("Key failed to encrypt"); var decryptedKeyBytes = helper.RsaDecryptToBytes(encryptedKeyBytes); var decryptedIvBytes = helper.RsaDecryptToBytes(encryptedIvBytes); originalKey.ShouldBeEquivalentTo(decryptedKeyBytes); originalIv.ShouldBeEquivalentTo(decryptedIvBytes); }