Encription.Library 1.0.2

Database Encryption README

This README provides instructions on encrypting database fields in your ASP.NET Core application using an attribute and middleware.

Step 1: Attribute Setup

Apply the [EncryptProperty] attribute to the properties of type string that you want to encrypt in your database entity classes.

using System.ComponentModel.DataAnnotations;

public class YourEntity
{
    [EncryptProperty]
    public string Name { get; set; } = null!;
}

Step 2: Middleware Configuration

Add middleware inside the OnModelCreating method of your DbContext class to configure database encryption.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.UseEncryption();
    base.OnModelCreating(modelBuilder);
}

Usage

  1. When you save an entity instance with properties marked with the [EncryptProperty] attribute, the middleware will automatically encrypt those properties before storing them in the database.

  2. When you retrieve an entity instance, the middleware will automatically decrypt the encrypted properties before returning them.

Additional Configuration

If you need more advanced encryption configurations, you can customize the encryption middleware according to your requirements. For example, you can specify the encryption algorithm, encryption keys, or encryption settings.

Conclusion

By following the steps outlined in this README, you can easily encrypt database fields in your ASP.NET Core application using attributes and middleware, providing an additional layer of security for sensitive data stored in your database.

No packages depend on Encription.Library.

Version Downloads Last updated
1.0.2 98 6/9/2024
1.0.1 9 6/9/2024
1.0.0 85 5/22/2024