AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption
6.0.2
See the version list below for details.
dotnet add package AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption --version 6.0.2
NuGet\Install-Package AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption -Version 6.0.2
<PackageReference Include="AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption" Version="6.0.2" />
paket add AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption --version 6.0.2
#r "nuget: AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption, 6.0.2"
// Install AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption as a Cake Addin #addin nuget:?package=AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption&version=6.0.2 // Install AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption as a Cake Tool #tool nuget:?package=AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption&version=6.0.2
AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption
AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption is a NPGSQL Extension that supports native PostgreSql's Raw Encryption Functions (encrypt_iv,decrypt_iv with aes-cbc/pad:pkcs) (see section F.26.4. Raw Encryption Functions). Meaning this will support search query on encrypted columns. Well, this is good if you have GDPR compliance requirement.
Note
If you use this make sure your application to the PostgreSQL service is use a encrypted connection because this will transmit the RAW PASSWORD over the network
. You can enforce it in the connection string. example -
{
"DefaultConnection": "Server=127.0.0.1;port=5432;user id=postgres;password=postgres;database=AESTester;pooling=true;Encoding=UTF8;SSL Mode=Require;Trust Server Certificate=true;"
}
take a look at SSL Mode=Require;Trust Server Certificate=true;
AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption
targets net6.0
. The package has following dependencies
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.2" />
When you choose the version choose with the .Net Core
Version for example if .Net Core
version is 5.0 then choose AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption
version 5.0.x
setup
NuGet install:
Install-Package AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption
DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseEncryptionFunctions("yourpassword",EncKeyLength.L128);
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.HasPostgresExtension("pgcrypto");
builder.UseEncryptAttribute("yourpassword",EncKeyLength.L128);
}
Replace yourpassword
with your password
Example of use
NpgsqlEncrypt
Annotation Use
public class TestModel
{
public string Id { get; set; } = Guid.NewGuid().ToString();
[NpgsqlEncrypt] #Use NpgsqlEncrypt attribute to denote the property must be encrypt in database
public string Name { get; set; }
}
How to use it in search query
var searchTest = _dbContext.TModels.Where(x => x.Name.NpgDecrypt().Contains("test")).ToList();
Above Linq will convert to a Native Sql Query that will decrypt the column before it do a search.
You can find a example that I have used in the EncryptionTest
project Tests\Tests.cs
and WebApplication
Project WeatherForecastController.cs
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 6.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.4 | 1,192 | 7/16/2024 |
6.0.2.3 | 1,843 | 10/20/2023 |
6.0.2.2 | 14,070 | 2/17/2023 |
6.0.2.1 | 8,590 | 3/18/2022 |
6.0.2 | 1,033 | 1/19/2022 |
6.0.1.1 | 446 | 3/18/2022 |
6.0.1 | 446 | 1/19/2022 |
6.0.0.1 | 431 | 3/18/2022 |
6.0.0 | 1,514 | 1/19/2022 |
5.0.10.2 | 529 | 3/18/2022 |
5.0.10.1 | 2,004 | 10/25/2021 |
5.0.10 | 633 | 10/24/2021 |
3.1.2 | 938 | 3/18/2022 |
3.1.1.2 | 442 | 3/18/2022 |
3.1.1.1 | 423 | 10/24/2021 |
3.1.1 | 403 | 10/24/2021 |
3.1.0.2 | 445 | 3/18/2022 |
3.1.0.1 | 361 | 10/25/2021 |
3.1.0 | 399 | 10/24/2021 |