diff --git a/DigitalData.Core.Security/Cryptographer/RSACryptographerList.cs b/DigitalData.Core.Security/Cryptographer/RSACryptographerList.cs index f7ab7a7..6bfada7 100644 --- a/DigitalData.Core.Security/Cryptographer/RSACryptographerList.cs +++ b/DigitalData.Core.Security/Cryptographer/RSACryptographerList.cs @@ -19,6 +19,12 @@ namespace DigitalData.Core.Security.Cryptographer => _cryptographers.SingleOrDefault(crypt => _keyGenerator(crypt) == key) ?? throw new InvalidOperationException($"No {typeof(TRSACryptographer).GetType().Name.TrimStart('I')} found with Key: {key}."); + public bool TryGet(string key, out TRSACryptographer? cryptographer) + { + cryptographer = _cryptographers.SingleOrDefault(crypt => _keyGenerator(crypt) == key); + return cryptographer is not null; + } + public IEnumerator GetEnumerator() => _cryptographers.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();