Example #1
0
        public void Decrypt_Should_ReturnExpectedResult_When_KeyIsStoredInConfig()
        {
            // Arrange
            AddKeysToEnvironment();

            var publicKey  = RsaPublicKey.LoadFromEnvironment();
            var privateKey = RsaPrivateKey.LoadFromEnvironment();

            var e1 = new RsaEncryption();
            var e2 = new RsaEncryption();

            // Act
            var encryptedData = e1.Encrypt(new EncryptionData(Secret), publicKey);
            var decryptedData = e2.Decrypt(encryptedData, privateKey);

            // Assert
            Assert.Equal(decryptedData.Text, Secret);

            RemoveKeysToEnvironment();
        }
Example #2
0
 public void LoadFromConfig_Should_ThrowExceptionWhenConfigAppSettingsEmpty() =>
 Assert.Throws <ArgumentException>(() => RsaPublicKey.LoadFromEnvironment());