Create key file if not exist

This commit is contained in:
2021-08-02 10:01:21 -04:00
parent ffcb6a12df
commit ca6745e0d4

View File

@ -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)