feat(RSAExtensions) : Methoden hinzugefügt, um einen Verschlüsseler anhand seines Ausstellers und seiner Zielgruppe aus einem Wörterbuch zu erhalten

This commit is contained in:
Developer 02 2024-11-18 17:56:21 +01:00
parent fee43c00ca
commit 4c379c2d4d
2 changed files with 12 additions and 1 deletions

View File

@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DigitalData.Core.Abstractions\DigitalData.Core.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,5 @@
using System.Security.Cryptography;
using DigitalData.Core.Abstractions.Security;
using System.Security.Cryptography;
namespace DigitalData.Core.Security.Extensions
{
@ -10,5 +11,11 @@ namespace DigitalData.Core.Security.Extensions
rsa.ImportFromPem(pem);
return rsa;
}
public static bool TryGetEncryptor(this IDictionary<string, IRSAEncryptor> pairs, string issuer, string audience, out IRSAEncryptor? encryptor)
=> pairs.TryGetValue($"{issuer}:{audience}", out encryptor);
public static IRSAEncryptor? GetEncryptor(this IDictionary<string, IRSAEncryptor> pairs, string issuer, string audience)
=> pairs.TryGetEncryptor(issuer: issuer, audience: audience, out var encryptor) ? encryptor : null;
}
}