From 988d1e2b16464c799445ba3104ab77f1efb82d3c Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Sat, 7 Dec 2024 03:26:00 +0100 Subject: [PATCH] feat(RSADecryptor): FileNotFoundEvent-Methode aktualisiert, um Datei zu erstellen, wenn nicht gefunden --- .../Cryptographer/RSADecryptor.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/DigitalData.Core.Security/Cryptographer/RSADecryptor.cs b/DigitalData.Core.Security/Cryptographer/RSADecryptor.cs index eb4cbec..f99ac5d 100644 --- a/DigitalData.Core.Security/Cryptographer/RSADecryptor.cs +++ b/DigitalData.Core.Security/Cryptographer/RSADecryptor.cs @@ -1,4 +1,5 @@ using DigitalData.Core.Abstractions.Security; +using DigitalData.Core.Security.Config; using DigitalData.Core.Security.Extensions; using System.Security.Cryptography; @@ -33,5 +34,22 @@ namespace DigitalData.Core.Security.Cryptographer else RSA.ImportFromPem(Pem); } + + public override void FileNotFoundEvent() + { + var new_decryptor = new RSADecryptor() + { + Pem = RSAFactory.Static.CreateRSAPrivateKeyPem(), + Encrypt = Encrypt + }; + + _pem = new_decryptor.Pem; + + if (PemPath is not null) + Task.Run(async () => + { + await File.WriteAllTextAsync(_pem, PemPath); + }); + } } } \ No newline at end of file