2026-03-16 19:15:04 +01:00
|
|
|
using System.Text;
|
|
|
|
|
using IdentityShroud.Core.Model;
|
2026-02-27 17:57:42 +00:00
|
|
|
using IdentityShroud.Core.Security;
|
|
|
|
|
|
|
|
|
|
namespace IdentityShroud.Core.Contracts;
|
|
|
|
|
|
|
|
|
|
public interface IDataEncryptionService
|
|
|
|
|
{
|
2026-03-16 19:15:04 +01:00
|
|
|
EncryptedValue Encrypt(RealmDek dek, ReadOnlySpan<byte> plain);
|
|
|
|
|
byte[] Decrypt(IReadOnlyList<RealmDek> deks, EncryptedValue input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class DataEncryptionServiceExtensions
|
|
|
|
|
{
|
|
|
|
|
public static string DecryptUtf8ToString(
|
|
|
|
|
this IDataEncryptionService des,
|
|
|
|
|
IReadOnlyList<RealmDek> deks,
|
|
|
|
|
EncryptedValue input)
|
|
|
|
|
{
|
|
|
|
|
return Encoding.UTF8.GetString(des.Decrypt(deks, input));
|
|
|
|
|
}
|
2026-02-27 17:57:42 +00:00
|
|
|
}
|