TPJ.Encrypt
2.0.0
See the version list below for details.
dotnet add package TPJ.Encrypt --version 2.0.0
NuGet\Install-Package TPJ.Encrypt -Version 2.0.0
<PackageReference Include="TPJ.Encrypt" Version="2.0.0" />
paket add TPJ.Encrypt --version 2.0.0
#r "nuget: TPJ.Encrypt, 2.0.0"
// Install TPJ.Encrypt as a Cake Addin #addin nuget:?package=TPJ.Encrypt&version=2.0.0 // Install TPJ.Encrypt as a Cake Tool #tool nuget:?package=TPJ.Encrypt&version=2.0.0
TPJ Encrypt library - Easily encrypt values. Simple, light weight, easy to setup!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net452 is compatible. net46 is compatible. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.5.2
- Microsoft.Extensions.Configuration.Abstractions (>= 1.0.2)
- Microsoft.Extensions.Options (>= 1.0.2)
-
.NETFramework 4.6
- Microsoft.Extensions.Configuration.Abstractions (>= 1.0.2)
- Microsoft.Extensions.Options (>= 1.0.2)
-
.NETFramework 4.6.1
- Microsoft.Extensions.Configuration.Abstractions (>= 1.0.2)
- Microsoft.Extensions.Options (>= 1.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.
V2.0.0 is only supporting full .net 4.5.2, 4.6, and 4.6.1. Once .NETStandard 2.0 is released this packaged will be updated to run using this. More detailed Examples will follow then.
ASP.Net Core full framework (4.5.2 4.6 4.6.1) Website / WebAPI Set up.
Within appsettings.json and add the following
{
"TPJ": {
"Encrypt": {
"EncryptionKey": "",
"Salt": "",
"KeySize": "",
}
}
}
EncryptionKey– (Required) Key used to lock the string down so it can only be decrypted using the same key
Salt - This size of the IV (in bytes) must = (keysize / 8). Default keysize is 256, so the IV must be 32 bytes long. Using a 16 character string gives us 32 bytes when converted to a byte array.
KeySize - by default its set to 256 which means you need a 32byte salt key if set to 128 you need a 16byte salt or 512 you need a 64 byte salt
Example appsettings.json setup –
{
"TPJ": {
"Encrypt": {
"EncryptionKey": "asdzgfh|£%^%TEGDSTEGbg54e523s",
"Salt": "tu89gaji343t89u2",
"KeySize": "256",
}
}
}
Once appsettings.json is done open StartUp.cs file and go to ConfigureServices
var settings = new TPJ.Encrypt.Models.EncryptSettings(Configuration);
services.Configure<TPJ.Encrypt.Models.EncryptSettings>(options =>
{
options.EncryptionKey = settings.EncryptionKey;
options.Salt = settings.Salt;
options.KeySize = settings.KeySize;
});
services.AddSingleton<TPJ.Encrypt.IEncryption, TPJ.Encrypt.IEncryption >();
Then using DI within asp.net core you can call IEncryption like so
private readonly TPJ.Encrypt.IEncryption _encryption;
public HomeController(TPJ.Encrypt.IEncryption encryption)
{
_encryption = encryption;
}
Then you might have this
public string EncryptString(string valueToEncrypt)
{
return _encryption.Encrypt(valueToEncrypt);
}
It really is that simple you will get an encrypted string returned. To then decrypt the string call _encryption.Decrypt(encryptedValue);