refactor(RSADecryptor): Lazy Loading in Encryptor Getter integriert, um die Leistung zu verbessern.

This commit is contained in:
Developer 02 2024-11-19 23:58:04 +01:00
parent 777a8a73ac
commit f28b43cc06

View File

@ -10,19 +10,18 @@ namespace DigitalData.Core.Security
public bool IsEncrypted => Password is not null;
public IRSAEncryptor Encryptor
{
get
{
return new RSAEncryptor()
{
Pem = _rsa.ExportRSAPublicKeyPem(),
Padding = Padding
};
}
}
private readonly Lazy<IRSAEncryptor> _lazyEncryptor;
internal RSADecryptor() { }
public IRSAEncryptor Encryptor => _lazyEncryptor.Value;
internal RSADecryptor()
{
_lazyEncryptor = new(() => new RSAEncryptor()
{
Pem = _rsa.ExportRSAPublicKeyPem(),
Padding = Padding
});
}
[OnDeserialized]
private void OnDeserialized(StreamingContext context) => Init();