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" />
paket add TPJ.Encrypt --version 3.0.0
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
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 –
Once appsettings.json is done open StartUp.cs file and add the following using -
then go to ConfigureServices
Then using DI within asp.net 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)
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 NuGet packages.
This package is not used by any popular GitHub repositories.