PanoramicData.Encryption 1.0.6

.NET 6.0
dotnet add package PanoramicData.Encryption --version 1.0.6
NuGet\Install-Package PanoramicData.Encryption -Version 1.0.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PanoramicData.Encryption" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PanoramicData.Encryption --version 1.0.6
#r "nuget: PanoramicData.Encryption, 1.0.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PanoramicData.Encryption as a Cake Addin
#addin nuget:?package=PanoramicData.Encryption&version=1.0.6

// Install PanoramicData.Encryption as a Cake Tool
#tool nuget:?package=PanoramicData.Encryption&version=1.0.6


Although you could use the nuget package, why would you trust it? Better to read and understand and copy the source into your project.

Seriously, there's only one file. Copy it. It's here.

To use:

   using PanoramicData.Encryption;

   // Preparation

   // Here is the plaintext we want to protect:
   var plaintext = "Hello, World!";
   // The encryption key should be a 32 byte array,
   // represented as a 64 character hex string.
   // NO NOT use this one.  It will work, but it is not secure.
   // DO NOT store your encryption keys in your source code.
   // Environment variables are one way to keep your data, keys and source code separate.
   // You could use var privateKey = Environment.GetEnvironmentVariable("PrivateKey") method to retrieve this.
   // So we have a working example, let's put it in code for now.
   var privateKey = "00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF";

   // Create the encryption service using the private key.
   var encryptionService = new EncryptionService(privateKey);

   // Encryption

   // EITHER 1) create cipherText and salt at the same time.
   // This is the recommended way to do it.
   (var cipherText, var salt) = encryptionService.Encrypt(plaintext);

   // OR 2) create your own salt first:
   var salt = "00112233445566778899AABBCCDDEEFF";
   (var cipherText2, var _) = encryptionService.Encrypt(plaintext, salt);

   // Storage
   // You should store the salt and cipherText in your database.
   // You may prefer to Base64 encode them before storing them, for storage efficiency.

   // ...

   // Retrieval
   // The salt and cipherText are safe for anyone to have access to.
   // Without the private key, no-one cannot decrypt the data.
   // Retrieve them from storage...

   // Decryption

   // You can decrypt the cipherText using the EncryptionService and the salt:
   var restoredPlainText = encryptionService.Decrypt(cipherText, salt);


   // Worst.  "Hello, World!"  Ever.
Product 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. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

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
1.0.6 783 6/20/2022
1.0.5 371 4/5/2022
1.0.4 323 4/4/2022

Initial release