22 lines
747 B
C#
22 lines
747 B
C#
using IRaCIS.Core.Infrastructure.Encryption;
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
using Microsoft.EntityFrameworkCore.ValueGeneration;
|
|
|
|
namespace IRaCIS.Core.Infra.EFCore;
|
|
|
|
/// <summary>
|
|
/// 某列保留前面几位,后续加密
|
|
/// </summary>
|
|
public class PartialEncryptionConverter : ValueConverter<string, string>
|
|
{
|
|
private readonly int _unencryptedPrefixLength;
|
|
|
|
public PartialEncryptionConverter(int unencryptedPrefixLength)
|
|
: base(
|
|
plainText => AesEncryption.EncryptPartial(plainText, unencryptedPrefixLength),
|
|
encryptedText => AesEncryption.DecryptPartial(encryptedText, unencryptedPrefixLength))
|
|
{
|
|
_unencryptedPrefixLength = unencryptedPrefixLength;
|
|
}
|
|
}
|