CryptoNet 1.0.0
See the version list below for details.
dotnet add package CryptoNet --version 1.0.0
NuGet\Install-Package CryptoNet -Version 1.0.0
<PackageReference Include="CryptoNet" Version="1.0.0" />
paket add CryptoNet --version 1.0.0
#r "nuget: CryptoNet, 1.0.0"
// Install CryptoNet as a Cake Addin
#addin nuget:?package=CryptoNet&version=1.0.0
// Install CryptoNet as a Cake Tool
#tool nuget:?package=CryptoNet&version=1.0.0
Introdution
CryptoNet is a simple and a lightweight symmetric and asymmetric RSA encryption NuGet library. It is a 100% native C# implementation based on RSACryptoServiceProvider class.
Installation
You can download CryptoNet via NuGet.
Versions
is latest version and are maintained.
Issues
Please report issues here.
Using / Documentation
Short intro
There are 2 ways to encrypt and decrypt content:
- Symmetric way (By default):
- Use same key to encrypt and decrypt.
- Asymmetric way
- You have 2 keys, Private and Public key.
- Use Public key to encrypt.
- Use Private key to decrypt.
- You need to generate RSA key pair first (Private/Public key).
You find the comlete and all examples here.
Here is some of the examples:
Example: Encrypt and Decrypt with Symmetric Key
ICryptoNet encryptClient = new CryptoNet(SymmetricKey);
Console.WriteLine("1- We will encrypt following:");
Console.WriteLine(ConfidentialDummyData);
var encrypted = encryptClient.EncryptFromString(ConfidentialDummyData);
Console.WriteLine("2- To:");
Console.WriteLine(CryptoNetUtils.BytesToString(encrypted));
ICryptoNet decryptClient = new CryptoNet(SymmetricKey);
var decrypted = decryptClient.DecryptToString(encrypted);
Console.WriteLine("3- And we will decrypt it back with correct key:");
Console.WriteLine(decrypted);
ICryptoNet decryptClientWithWrongKey = new CryptoNet("wrong key");
var decryptWithWrongKey = decryptClientWithWrongKey.DecryptToString(encrypted);
Console.WriteLine("4- And we will not be able decrypt it back with wrong key:");
Console.WriteLine(decryptWithWrongKey);
Example: Generate and Export Asymmetric Key (Private/Public) Key (RasKeyPair)
ICryptoNet cryptoNet = new CryptoNet("My-Secret-Key");
CryptoNetUtils.SaveKey(PrivateKeyFile, cryptoNet.ExportPrivateKey());
CryptoNetUtils.SaveKey(PublicKeyFile, cryptoNet.ExportPublicKey());
var certificate = CryptoNetUtils.LoadFileToString(PrivateKeyFile);
var publicKey = CryptoNetUtils.LoadFileToString(PublicKeyFile);
Example: Encrypt with Public Key and later Decrypt with Private Key
var certificate = CryptoNetUtils.LoadFileToString(RsaKeyPair);
// Export public key
ICryptoNet cryptoNet = new CryptoNet(certificate, true);
var publicKey = cryptoNet.ExportPublicKey();
CryptoNetUtils.SaveKey(PublicKeyFile, publicKey);
// Import public key and encrypt
var importPublicKey = CryptoNetUtils.LoadFileToString(PublicKeyFile);
ICryptoNet cryptoNetEncryptWithPublicKey = new CryptoNet(importPublicKey, true);
var encryptWithPublicKey = cryptoNetEncryptWithPublicKey.EncryptFromString(ConfidentialDummyData);
Console.WriteLine("1- This time we use a certificate public key to encrypt");
Console.WriteLine(CryptoNetUtils.BytesToString(encryptWithPublicKey));
ICryptoNet cryptoNetDecryptWithPublicKey = new CryptoNet(certificate, true);
var decryptWithPrivateKey = cryptoNetDecryptWithPublicKey.DecryptToString(encryptWithPublicKey);
Console.WriteLine("6- And use the same certificate to decrypt");
Console.WriteLine(decryptWithPrivateKey);
Contributing
I need your help, so if you have good knowledge of C# and Cryptography just grab one of the issues and add a pull request. The same is valid, if you have idea for improvement or adding new feature.
How to contribute:
Here is a link to learn how to contribute if you are not a ware of how to do it.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.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.