PanoramicData.Encryption 1.0.6

.NET 6.0
Install-Package PanoramicData.Encryption -Version 1.0.6
dotnet add package PanoramicData.Encryption --version 1.0.6
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PanoramicData.Encryption, 1.0.6"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

PanoramicData.Encryption

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);

   Console.WriteLine(restoredPlainText);

   // Worst.  "Hello, World!"  Ever.
Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
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 43 6/20/2022
1.0.5 101 4/5/2022
1.0.4 54 4/4/2022

Initial release