TPJ.Encrypt 3.0.0

TPJ Encrypt library - Easily encrypt values. Simple, light weight, easy to setup!

Install-Package TPJ.Encrypt -Version 3.0.0
dotnet add package TPJ.Encrypt --version 3.0.0
<PackageReference Include="TPJ.Encrypt" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TPJ.Encrypt --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Release Notes

V3.0.0+ only supports .netstandard2.0, which works in .net4.6.1 + / .netcore2.0 +. If you are using .net4.5.2 / .net 4.6 you can use TPJ.Encrypt V2.X.X.

ASP.Net Core 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 add the following using -

using TPJ.Encrypt;

then go to ConfigureServices


Then using DI within core you can call IEncrypt 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);

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.0.0 597 8/20/2017
2.0.1 302 7/14/2017
2.0.0 379 5/5/2017