CryptoNet alternatives and similar packages
Based on the "Cryptography" category.
Alternatively, view CryptoNet alternatives based on common mentions on social networks and blogs.
BouncyCastle7.3 7.1 L2 CryptoNet VS BouncyCastleBouncyCastle.NET Cryptography Library (Mirror)
SecurityDriven.Inferno5.0 2.1 L4 CryptoNet VS SecurityDriven.Inferno:white_check_mark: .NET crypto done right. Professionally audited.
libsodium-net4.9 0.0 L4 CryptoNet VS libsodium-netlibsodium for .NET - A secure cryptographic library
Pkcs11Interop4.1 0.0 L2 CryptoNet VS Pkcs11InteropManaged .NET wrapper for unmanaged PKCS#11 libraries
BCrypt.Net-Core3.4 0.0 L4 CryptoNet VS BCrypt.Net-CoreA .net Core port of BCrypt.net
StreamCryptor3.1 0.0 L1 CryptoNet VS StreamCryptorStream encryption & decryption with libsodium and protobuf
NaCl.Core2.1 6.7 CryptoNet VS NaCl.Core🔑 NaCl.Core, a cryptography library for .NET
Paseto.Core2.1 7.5 CryptoNet VS Paseto.Core🔑 Paseto.NET, a Paseto (Platform-Agnostic Security Tokens) implementation for .NET
HashLib1.7 0.0 L1 CryptoNet VS HashLibFork of HashLib project
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of CryptoNet or a related project?
:rocket: CryptoNet is simple, fast and a lightweight asymmetric and symmetric encryption NuGet library supporting .NET Standard 2.0 and C# 8.0 for cross platforms Windows, Linux, iOS. It is a 100% native C# implementation based on Microsoft cryptography. It does not depending on other library.
You can download CryptoNet via NuGet.
is latest version and are maintained.
- !!!Breaking change!!!
- Refactoring RSA asymmetric encryption.
- Introducing AES symmetric encryption.
- Adapt RSA PEM exporting and importing helpers with example.
- Windows symmetric encryption from v.1.6 is no longer avaible.
- Adapt RSA instance for customization.
- Adapt RSA customization example for PEM exporting and importing.
- Reintroducing symmetric encryption only for Windows OS.
- Adding Source Link, Deterministic and Compiler Flags to NuGet package.
- Readme enhancement.
- Change from RSACryptoServiceProvider to RSA factory that support cross platforms (Windows, Linux, iOS).
- No longer support for symmetric encryption from version 1.0.0.
- Console examples and Unit testing refactored.
- Support for X509Certificate2.
- Ability to encrypt and decrypt files like, images, word, excel etc.
- Improvement documentation
Please report issues here.
How to use
The library can be used in 2 ways:
- Symmetric way
- Asymmetric way
You use the same key (any secret key) for encryption and decryption.
With asymmetric way, the library can use its own self-generated RSA key pairs (Private/Public key) to encrypt and decrypt content.
You can store the private key on one or more machines. The public key can easily distribute to all clients.
Note: Please be aware of not to distribute private key publicly and keep it in a safe place. If private key mistakenly gets exposed, you need to re-issue new keys. The content that is already encrypted with private key, can not be decrypted back with the new generated private key. So before updating private key or deleting the old key ensure all your content are decrypted, other wise you lose the content.
It is also possible to use asymmetric keys of X509 Certificate instead of generating your own keys.
The main concept with asymmetric encryption, is that you have a Private and Public key. You use Public key to encrypt the content with and use Private key to decrypt the content back again.
You find the comlete and all examples for:
Here is some of the examples:
Example: Encrypt and Decrypt Content With Symmetric Key
In this example CryptoNetAes generate random key and iv, hence we use the same instance we can both encrypt and decrypt.
ICryptoNet cryptoNet = new CryptoNetAes(); var key = cryptoNet.ExportKey(); ICryptoNet encryptClient = new CryptoNetAes(key); var encrypt = encryptClient.EncryptFromString(ConfidentialDummyData); ICryptoNet decryptClient = new CryptoNetAes(key); var decrypt = decryptClient.DecryptToString(encrypt); Debug.Assert(ConfidentialDummyData == decrypt);
Example: Encrypt and Decrypt Content With Export and Import Self-Generated Symmetric Key
ICryptoNet cryptoNet = new CryptoNetAes(); var file = new FileInfo(SymmetricKeyFile); cryptoNet.ExportKeyAndSave(file); Debug.Assert(File.Exists(file.FullName)); var encrypt = cryptoNet.EncryptFromString(ConfidentialDummyData); ICryptoNet cryptoNetKeyImport = new CryptoNetAes(file); var decrypt = cryptoNetKeyImport.DecryptToString(encrypt); Debug.Assert(ConfidentialDummyData == decrypt);
Example: Generate Asymmetric Rsa key pair, Export Private and Public, use Public key to encrypt with and Use Private key to decrypt with
ICryptoNet cryptoNet = new CryptoNetRsa(); cryptoNet.ExportKeyAndSave(new FileInfo(PrivateKeyFile), true); cryptoNet.ExportKeyAndSave(new FileInfo(PublicKeyFile), false); Debug.Assert(File.Exists(new FileInfo(PrivateKeyFile).FullName)); Debug.Assert(File.Exists(new FileInfo(PublicKeyFile).FullName)); ICryptoNet cryptoNetPubKey = new CryptoNetRsa(new FileInfo(PublicKeyFile)); var encrypt = cryptoNetPubKey.EncryptFromString(ConfidentialDummyData); ICryptoNet cryptoNetPriKey = new CryptoNetRsa(new FileInfo(PrivateKeyFile)); var decrypt = cryptoNetPriKey.DecryptToString(encrypt); Debug.Assert(ConfidentialDummyData == decrypt);
Example: Use X509 certificate to Encrypt with Public Key and later Decrypt with Private Key
// Find and replace CN=Maytham with your own certificate X509Certificate2? certificate = CryptoNetUtils.GetCertificateFromStore("CN=Maytham"); ICryptoNet cryptoNetWithPublicKey = new CryptoNetRsa(certificate, KeyType.PublicKey); var encryptWithPublicKey = cryptoNetWithPublicKey.EncryptFromString(ConfidentialDummyData); ICryptoNet cryptoNetWithPrivateKey = new CryptoNetRsa(certificate, KeyType.PrivateKey); var decryptWithPrivateKey = cryptoNetWithPrivateKey.DecryptToString(encryptWithPublicKey); Debug.Assert(ConfidentialDummyData == decryptWithPrivateKey);
Build and Testing
You have different options to build and run unit test from:
- Visual Studio 2019/2022.
- dotnet command line.
- start Powershell, and run
build.ps1from solution folder.
- Docker, run following command from solution folder:
docker build . --file .\Dockerfile --tag cryptonet-service:latest
You are more than welcome to contribute in one of the following ways:
- Basic: Give input, suggestion for improvement by creating issue and lable it https://github.com/maythamfahmi/CryptoNet/issues
- Advance: if you have good knowledge of C# and Cryptography just grab one of the issues, feature or refactoring and add a pull request.
- Documentation: Add, update or improve documentation, by makeing pull request.
How to contribute:
Here is a link to learn how to contribute if you are not a ware of how to do it.
*Note that all licence references and agreements mentioned in the CryptoNet README section above are relevant to that project's source code only.