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

This commit is contained in:
Developer 02 2024-12-07 03:26:00 +01:00
parent 4e0e907313
commit 988d1e2b16

View File

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