Skip to content

Commit

Permalink
#11 refactoring improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
maythamfahmi committed Dec 23, 2021
1 parent 53ba8c0 commit 8f57091
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions CryptoNetLib/CryptoNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,17 @@ public class CryptoNet : ICryptoNet
public CryptoNet(string symmetricKeyOrAsymmetricKey, bool rsaKey = false)
{
if (string.IsNullOrWhiteSpace(symmetricKeyOrAsymmetricKey))
{
throw new Exception("Missing symmetric key Or asymmetric key");
}

var parameters = new CspParameters();
if (!rsaKey)
{
parameters.KeyContainerName = symmetricKeyOrAsymmetricKey;
}

_rsa = new RSACryptoServiceProvider(parameters)
{
PersistKeyInCsp = true
};
_rsa = new RSACryptoServiceProvider(parameters);
_rsa.PersistKeyInCsp = true;

if (rsaKey)
{
_rsa.FromXmlString(symmetricKeyOrAsymmetricKey);
}
}

/// <summary>
Expand Down

0 comments on commit 8f57091

Please sign in to comment.