Created
April 21, 2016 10:34
-
-
Save zhekaby/475508407daf15cc627aabef4d972d60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IAsymetricProviderFactory | |
{ | |
void Initialize(byte[] cert); | |
IAsymetricProvider GetProvider(); | |
IAsymetricProvider GetProvider(SecureString password); | |
} | |
public class RsaProviderFactory : IAsymetricProviderFactory | |
{ | |
private byte[] _cert; | |
public void Initialize(byte[] cert) | |
{ | |
_cert = cert; | |
} | |
public IAsymetricProvider GetProvider() | |
{ | |
var provider = new RsaProvider(); | |
provider.Initialize(new X509Certificate2(_cert)); | |
return provider; | |
} | |
public IAsymetricProvider GetProvider(SecureString password) | |
{ | |
var provider = new RsaProvider(); | |
provider.Initialize(new X509Certificate2(_cert, password)); | |
return provider; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment