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);