From ee3060158e9e6fc11996a6967cd3e299f40f7507 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Mon, 18 Nov 2024 17:35:01 +0100 Subject: [PATCH] refactor(RSADecryptor): Konstruktionsmethode intern gemacht --- DigitalData.Core.Security/RSADecryptor.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/DigitalData.Core.Security/RSADecryptor.cs b/DigitalData.Core.Security/RSADecryptor.cs index a8ad4a7..04be07a 100644 --- a/DigitalData.Core.Security/RSADecryptor.cs +++ b/DigitalData.Core.Security/RSADecryptor.cs @@ -22,22 +22,12 @@ namespace DigitalData.Core.Security } } - public RSADecryptor() { } - - public RSADecryptor(string pem, string? password = null) - { - Pem = pem; - Password = password; - Initialize(); - } + internal RSADecryptor() { } [OnDeserialized] - private void OnDeserialized(StreamingContext context) - { - Initialize(); - } + private void OnDeserialized(StreamingContext context) => Init(); - private void Initialize() + private IRSADecryptor Init() { if (string.IsNullOrWhiteSpace(Pem)) throw new InvalidOperationException("Pem cannot be null or empty."); @@ -46,6 +36,8 @@ namespace DigitalData.Core.Security _rsa.ImportFromPem(Pem); else _rsa.ImportFromEncryptedPem(Pem, Password.AsSpan()); + + return this; } public byte[] Decrypt(byte[] data) => _rsa.Decrypt(data, Padding);