fix(Core.Security): pem-Importprozess in den Initilizer mehetods verschoben

This commit is contained in:
Developer 02
2024-11-18 17:14:42 +01:00
parent eccf2b32ce
commit 26a68cd477
3 changed files with 32 additions and 5 deletions

View File

@@ -5,9 +5,17 @@ namespace DigitalData.Core.Security
{
public class RSAEncryptor : RSACryptographer, IRSAEncryptor, IRSACryptographer
{
public RSAEncryptor()
{
_rsa.ImportFromPem(Pem);
public override required string Pem
{
get => base.Pem;
init
{
if (string.IsNullOrWhiteSpace(Pem))
throw new InvalidOperationException("Pem cannot be null or empty.");
_rsa.ImportFromPem(base.Pem);
base.Pem = value;
}
}
public byte[] Encrypt(byte[] data) => _rsa.Encrypt(data, Padding);