AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption
3.1.1
See the version list below for details.
dotnet add package AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption --version 3.1.1
NuGet\Install-Package AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption -Version 3.1.1
<PackageReference Include="AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption" Version="3.1.1" />
paket add AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption --version 3.1.1
#r "nuget: AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption, 3.1.1"
// Install AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption as a Cake Addin #addin nuget:?package=AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption&version=3.1.1 // Install AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption as a Cake Tool #tool nuget:?package=AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption&version=3.1.1
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 netstandard2.0
. The package has following dependencies
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.1" />
When you choose the version choose with the .Net Core
Version for example if .Net Core
version is 3.1 then choose AltairCA.EntityFrameworkCore.PostgreSQL.ColumnEncryption
version 3.1.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 | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 3.1.1)
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,245 | 7/16/2024 |
6.0.2.3 | 1,844 | 10/20/2023 |
6.0.2.2 | 14,073 | 2/17/2023 |
6.0.2.1 | 8,594 | 3/18/2022 |
6.0.2 | 1,034 | 1/19/2022 |
6.0.1.1 | 447 | 3/18/2022 |
6.0.1 | 447 | 1/19/2022 |
6.0.0.1 | 432 | 3/18/2022 |
6.0.0 | 1,515 | 1/19/2022 |
5.0.10.2 | 530 | 3/18/2022 |
5.0.10.1 | 2,005 | 10/25/2021 |
5.0.10 | 636 | 10/24/2021 |
3.1.2 | 939 | 3/18/2022 |
3.1.1.2 | 443 | 3/18/2022 |
3.1.1.1 | 424 | 10/24/2021 |
3.1.1 | 404 | 10/24/2021 |
3.1.0.2 | 446 | 3/18/2022 |
3.1.0.1 | 362 | 10/25/2021 |
3.1.0 | 400 | 10/24/2021 |