-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSAProvider.cs
46 lines (42 loc) · 1.08 KB
/
RSAProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Security.Cryptography;
namespace authority
{
public interface IPublicRSAProvider : IDisposable
{
public RSA Key { get; }
}
public interface IPrivateRSAProvider : IDisposable
{
public RSA Key { get; }
}
public class PublicRSAProvider : IPublicRSAProvider
{
public RSA Key { get; }
public PublicRSAProvider(string path)
{
Key = RSA.Create();
if (File.Exists(path))
Key.ImportFromPem(File.ReadAllText(path).ToCharArray());
}
public void Dispose()
{
Key.Dispose();
GC.SuppressFinalize(this);
}
}
public class PrivateRSAProvider : IPrivateRSAProvider
{
public RSA Key { get; }
public PrivateRSAProvider(string path)
{
Key = RSA.Create();
if (File.Exists(path))
Key.ImportFromPem(File.ReadAllText(path).ToCharArray());
}
public void Dispose()
{
Key.Dispose();
GC.SuppressFinalize(this);
}
}
}