refactor(RSADecryptor): Lazy Loading in Encryptor Getter integriert, um die Leistung zu verbessern.
This commit is contained in:
parent
777a8a73ac
commit
f28b43cc06
@ -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;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new RSAEncryptor()
|
|
||||||
{
|
|
||||||
Pem = _rsa.ExportRSAPublicKeyPem(),
|
|
||||||
Padding = Padding
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal RSADecryptor() { }
|
public IRSAEncryptor Encryptor => _lazyEncryptor.Value;
|
||||||
|
|
||||||
|
internal RSADecryptor()
|
||||||
|
{
|
||||||
|
_lazyEncryptor = new(() => new RSAEncryptor()
|
||||||
|
{
|
||||||
|
Pem = _rsa.ExportRSAPublicKeyPem(),
|
||||||
|
Padding = Padding
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[OnDeserialized]
|
[OnDeserialized]
|
||||||
private void OnDeserialized(StreamingContext context) => Init();
|
private void OnDeserialized(StreamingContext context) => Init();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user