refactor(RSADecryptor): Konstruktionsmethode intern gemacht
This commit is contained in:
parent
4e615d7e39
commit
ee3060158e
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user