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 bool IsEncrypted => Password is not null;
public IRSAEncryptor Encryptor private readonly Lazy<IRSAEncryptor> _lazyEncryptor;
public IRSAEncryptor Encryptor => _lazyEncryptor.Value;
internal RSADecryptor()
{ {
get _lazyEncryptor = new(() => new RSAEncryptor()
{
return new RSAEncryptor()
{ {
Pem = _rsa.ExportRSAPublicKeyPem(), Pem = _rsa.ExportRSAPublicKeyPem(),
Padding = Padding Padding = Padding
}; });
} }
}
internal RSADecryptor() { }
[OnDeserialized] [OnDeserialized]
private void OnDeserialized(StreamingContext context) => Init(); private void OnDeserialized(StreamingContext context) => Init();