Version 1.0 - Initial Release
- Password Based Encryption
- RSA Public/Private Key Encryption
Version 2.1
- .NET 6 Update
- Added ECC Encryption
Version 2.1.2
- Added back the ability to work with Pkcs8 Encrypted Keys
Version 3.0.0
- .NET 9 Update
- Complete rewrite for easier use.
- Supports logging via ILogger interface
- Supports multiple forms of dependency injection
Version 3.1.0
- Replaced all .Net Ecc Cryptography Next Generation (CNG) with BouncyCastle code
Version 3.2.0
- Updated RSA Keys to use Encrypted PEM format same as ECC Keys
- Replaced all .Net Rsa Cryptography Next Generation (CNG) with BouncyCastle code
Version 3.5.0
- Added ability to default many options via ICryptoSharkConfiguration
- Internal code updates to make future enhaemnts easier
- Exposed all the internal parts allowing supplying the desired options
- Hash Alorythm for verifying data integrity can now be chosen
- RSA Padding for RSA Encryption can now be set with stanard strings
- Example: 'OAEPWithSHA-256AndMGF1Padding'
- Performance Enhancements
- Added option to compress data before encryption useing Huffman Coding
- Huffman Coding is very fast even over large data and will only slightly reduce speed
- Benchmark on 1Mb Data on Intel Core Ultra 285
| Method | Mean | Error | StdDev | |---------------------- |---------:|--------:|---------:| | EncryptNoCompresstion | 108.5 ms | 8.41 ms | 24.79 ms | | EncryptCompresstion | 104.1 ms | 7.72 ms | 22.63 ms |
Version 3.5.1
- Minor Security Enhancements
- Password is no supplyed as a char[] not string and is cleard once converted to SecureString
Code written on macOS & Windows 11
The concept is to have a simple and powerful took for Data Encryption with cross platform support (Windows, macOS, Linux).
BouncyCastle is the core of the Encryption and Decryption.
Encryption is done with a 256 Bit Key using Galois/Counter Mode (GCM). The following encryption algorithms are supported:
Designed to fit your workflow, all public classes have interfaces for easy dependency injection
- Factory for Creation
- Static Create Methods
- Traditional Constructiors
- As of 3.1 Ecc Keys are in the Encrypted PEM Format. Yu can use ones created elsewhere if you want even, simply read the PEM file into a byte array and pass it in as the Ecc Private Key along with the passwor. So this gives you the flexibity to use ones created elsewhere, i.e. open ssl.
- As of 3.2 Rsa Keys are stored the same way.
-----BEGIN EC PRIVATE KEY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oROYcqz45nBnqUa9m
H4ygcpUQWAfOeI9kB9lrUlkb3KqZxxMQxANsDs/USxC4gELNZKsMT7ufK8gG2j+n
/Tq2Ovldz6AupHfy0f3UEKUJsOgbKCoVL6WiW0Lzr9Nu9kYj/aHLuw7m343da7NB
KX9pftNqikwaIe91HnpUyNXji7lENcOwif2EXT8uRBTJJ+Ea+0JJwna5x8vZGrcx
EMlRbbvGzmQA+vr9tpaWKT/Qak86OGRubusWWjDxrQX/yPgciBJfMgI1ezVPR4vj
9Am4rd25k4jh/K8hSRcFkKdWO/81GTaQtVVpv2hjBaaoZdHxPcWrHoNRR2ktq5XS
7CyXPJIg1IsZImXgvBTtI/iiOPeo+TIG/2ich5KlGlIilqdDwg+R67xasn2Zcsfr
3eip9Yx+B8WkcDe6l900bRQLpuQ/7C5Kmdlw5m5GbDxsQUj8SiScc2tBtai1V63L
VfeIOQ41hD/WJehRBGMRzspUwNhs0FIO+QjHJW1ikWW8dJryKF/YpWr+1sTot3ri
6yaSgvKZzsVaVPrGIxhTH8FuNvlODXgnIOfNVS0hMDE=
-----END RSA PRIVATE KEY-----
Create a new CryptoSharkConfiguration (Or derive your own from ICryptoSharkConfiguration)
- Example:
ryptoSharkConfiguration configuration = new CryptoSharkConfiguration();
var factory = CryptoSharkFactory.CreateCryptoSharkFactory(ilogger, configuration);
var ecc = factory.CreateAsymmetricCryptography(CryptographyType.EllipticalCurveCryptography);
var rsa = factory.CreateAsymmetricCryptography(CryptographyType.RivestShamirAdlemanCryptography);
var pbe = factory.CreateSymmetricCryptography();
var utilities = factory.CreateCryptographyUtilities();
- AsymetricEncryptionRequest
- SemetricEncryptionRequest