Browse Source

Create key file if not exist

master
Gregory Rudolph 3 years ago
parent
commit
ca6745e0d4
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 12
      PrivateData.cs

12
PrivateData.cs

@ -6,12 +6,18 @@ using System; @@ -6,12 +6,18 @@ using System;
class PrivateData
{
private RSACryptoServiceProvider RSA;
private string keyFile = "KeyInfo.xml";
public PrivateData()
{
RSA = new RSACryptoServiceProvider();
RSA.FromXmlString(File.ReadAllText("KeyInfo.xml"));
if (File.Exists(keyFile)) {
RSA = new RSACryptoServiceProvider();
RSA.FromXmlString(File.ReadAllText(keyFile));
} else {
RSA = new RSACryptoServiceProvider(4096);
string KeyInfo = RSA.ToXmlString(true);
File.WriteAllText(keyFile, KeyInfo);
}
}
public string EncryptString(string input)

Loading…
Cancel
Save