A simple, high-performance string encryption and decryption extension library using AES (Advanced Encryption Standard) cryptography.
- Simple API: Easy-to-use extension methods for string encryption/decryption
- AES Encryption: Uses industry-standard AES encryption algorithm
- Custom Keys: Support for custom encryption keys
- High Performance: Optimized for speed and efficiency
- Multi-Framework: Supports .NET 6.0, 7.0, 8.0, and 9.0
- Secure: Implements proper cryptographic practices
PM> install-package Fondness.Cipher
dotnet add package Fondness.CipherInstall this package using the NuGet package manager. You don't need any configuration on the application, just call the string extension methods:
string input = "Hello World!";
var encryptedValue = value.ToEncrypt();
var decryptValue = encryptedValue.ToDecrypt();You can also provide your custom encryption key as follows:
string input = "Hello World!";
string encryptionKey = "abc123";
var encryptedValue = value.ToEncrypt(encryptionKey);
var decryptValue = encryptedValue.ToDecrypt(encryptionKey);Make sure you provide the same encryption key for both encryption and decryption.
- Key Consistency: Always use the same encryption key for both encryption and decryption
- Key Security: Store your custom encryption keys securely (environment variables, key vaults, etc.)
- Key Length: Custom keys should be sufficiently long for security (recommended: 32+ characters)
- Exception Handling: Handle potential exceptions for invalid inputs or wrong keys
- Uses AES encryption with PBKDF2 key derivation
- Generates unique encrypted outputs for the same input (due to IV usage)
- Invalid decryption attempts with wrong keys will result in garbled output or exceptions
- Base64 encoding is used for the encrypted output string format
try
{
string encrypted = "invalid-base64-string";
string decrypted = encrypted.ToDecrypt();
}
catch (FormatException)
{
// Handle invalid Base64 input
}
catch (ArgumentNullException)
{
// Handle null input
}
catch (CryptographicException)
{
// Handle decryption failures
}- .NET 6.0
- .NET 7.0
- .NET 8.0
- .NET 9.0
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Initial release
- Basic encryption/decryption functionality
- Support for custom encryption keys
- Multi-framework support
© Fondness Open Source. Licensed under the APACHE.