using DigitalData.Core.Abstractions.Security; using Microsoft.Extensions.Logging; namespace DigitalData.Core.Security { public class AsymCryptService : RSAFactory, IAsymCryptService { private readonly IDictionary _decryptors; public IRSADecryptor this[string key] { get => _decryptors[key]; set => _decryptors[key] = value; } public Func RSAKeyNameFormatter { get; } public AsymCryptService(ILogger logger, IDictionary decryptors, Func rsaKeyNameFormatter) : base() { _decryptors = decryptors ?? new Dictionary(); RSAKeyNameFormatter = rsaKeyNameFormatter; logger?.LogInformation("Core.Secrets version: {Version}, Created on: {CreationDate}.", Secrets.Version, Secrets.CreationDate.ToString("dd.MM.yyyy")); } public bool TryGetRSADecryptor(string key, out IRSADecryptor? decryptor) => _decryptors.TryGetValue(key, out decryptor); } }