Create key file if not exist
This commit is contained in:
@ -6,12 +6,18 @@ using System;
|
|||||||
class PrivateData
|
class PrivateData
|
||||||
{
|
{
|
||||||
private RSACryptoServiceProvider RSA;
|
private RSACryptoServiceProvider RSA;
|
||||||
|
private string keyFile = "KeyInfo.xml";
|
||||||
|
|
||||||
public PrivateData()
|
public PrivateData()
|
||||||
{
|
{
|
||||||
RSA = new RSACryptoServiceProvider();
|
if (File.Exists(keyFile)) {
|
||||||
RSA.FromXmlString(File.ReadAllText("KeyInfo.xml"));
|
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)
|
public string EncryptString(string input)
|
||||||
|
|||||||
Reference in New Issue
Block a user