Вот мой код:
Код: Выделить всё
public class Encrptconfig : IEntityTypeConfiguration
{
public void Configure(EntityTypeBuilder builder)
{
builder.IsMultiTenant();
builder.Property(e => e.Name)
.IsEncrypted(SoftFluent.ComponentModel.DataAnnotations.StorageFormat.Base64)
.IsRequired();
}
}
public class DataEncryption : AuditableEntity, IAggregateRoot
{
public string? Name { get; set; }
public string? Email { get; set; }
}
public class ApplicationDbContext : BaseDbContext
{
private readonly IEncryptionProvider _provider;
public ApplicationDbContext()
{
var encryptionKeyBytes = Convert.FromBase64String("TGVhZHJhdA==");
var encryptionIvBytes = Convert.FromBase64String("TGVhZHJhdA==");
_provider = new AesProvider(encryptionKeyBytes, encryptionIvBytes);
}
public DbSet DataEncryption => Set();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.UseEncryption(_provider);
base.OnModelCreating(modelBuilder);
}
}
Я ожидаю, что при сохранении данных в таблице DataEncryption свойство Name должно храниться в зашифрованном формате, и когда я получить его, я должен получить расшифрованное значение. Однако этого не происходит.
Кто-нибудь знает, что может пойти не так? Любая помощь будет оценена!`
Подробнее здесь: https://stackoverflow.com/questions/791 ... ng-as-expe