-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathLicenseAdmin.cs
39 lines (32 loc) · 1.06 KB
/
LicenseAdmin.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace DotNetLicensing
{
public class LicenseAdmin
{
public string LoadKeyPairs(string file)
{
StreamReader stream = System.IO.File.OpenText(file);
return stream.ReadToEnd();
}
public void CreateKeyPairs(string directory)
{
RSACryptoServiceProvider key = new RSACryptoServiceProvider(2048);
string publicPrivateKeyXML = key.ToXmlString(true);
string publicOnlyKeyXML = key.ToXmlString(false);
StringToFile(directory + "_public.xml", publicOnlyKeyXML);
StringToFile(directory + "_private.xml", publicPrivateKeyXML);
}
private void StringToFile(string outfile, string data)
{
StreamWriter outStream = System.IO.File.CreateText(outfile);
outStream.Write(data);
outStream.Close();
}
}
}