feat(RSAEncryptor): FileNotFoundEvent-Methode aktualisiert, um Datei zu erstellen, wenn nicht gefunden

This commit is contained in:
Developer 02 2024-12-07 03:24:29 +01:00
parent 0bfec426d4
commit 4e0e907313
2 changed files with 18 additions and 1 deletions

View File

@ -5,7 +5,7 @@ namespace DigitalData.Core.Security.Cryptographer
{
public class RSACryptographer : IRSACryptographer
{
private string? _pem;
protected string? _pem;
public string Pem
{

View File

@ -1,4 +1,5 @@
using DigitalData.Core.Abstractions.Security;
using DigitalData.Core.Security.Config;
using DigitalData.Core.Security.Extensions;
namespace DigitalData.Core.Security.Cryptographer
@ -16,5 +17,21 @@ namespace DigitalData.Core.Security.Cryptographer
base.Init();
RSA.ImportFromPem(base.Pem);
}
public override void FileNotFoundEvent()
{
var new_decryptor = new RSADecryptor()
{
Pem = RSAFactory<RSAFactoryParams>.Static.CreateRSAPrivateKeyPem()
};
_pem = new_decryptor.Encryptor.Pem;
if (PemPath is not null)
Task.Run(async () =>
{
await File.WriteAllTextAsync(_pem, PemPath);
});
}
}
}