SharpCipher 1.0.0
dotnet add package SharpCipher --version 1.0.0
NuGet\Install-Package SharpCipher -Version 1.0.0
<PackageReference Include="SharpCipher" Version="1.0.0" />
paket add SharpCipher --version 1.0.0
#r "nuget: SharpCipher, 1.0.0"
// Install SharpCipher as a Cake Addin #addin nuget:?package=SharpCipher&version=1.0.0 // Install SharpCipher as a Cake Tool #tool nuget:?package=SharpCipher&version=1.0.0
SharpCipher
SharpCipher is a C# implementation of a symmetric encryption algorithm that uses the AES encryption algorithm in CBC mode. It also employs key derivation using PBKDF2 with SHA-1 as the underlying hash function.
Usage
To use SharpCipher, you can create a new instance of the Cipher class and call its Encrypt and Decrypt methods to encrypt and decrypt data, respectively. Here's an example:
using SharpCipher;
// ...
var cipher = new Cipher();
var key = "my secret key";
var plaintext = "Hello, world!";
var ciphertext = cipher.Encrypt(plaintext, key);
var decrypted = cipher.Decrypt(ciphertext, key);
Console.WriteLine(decrypted); // Output: Hello, world!
Note that you should use a strong and unique key for each encryption to ensure the confidentiality of the data.
API
Cipher
The Cipher
class provides methods for encrypting and decrypting data using AES in CBC mode with key derivation using PBKDF2.
Encrypt(plainText: string, key: string) → string
Encrypts the input plaintext using AES in CBC mode with a randomly generated IV and key derived from the input key using PBKDF2.
plainText
- The plaintext to encrypt.key
- The key to use for encryption.
Returns the ciphertext as a base64-encoded string.
Throws a CipherException
if the plaintext or key is null white space or empty.
Decrypt(ciphertext: string, key: string) → string
Decrypts the input ciphertext using AES in CBC mode with the key derived from the input key using PBKDF2.
ciphertext
- The ciphertext to decrypt, as a base64-encoded string.key
- The key to use for decryption.
Returns the decrypted plaintext as a string.
Throws a CipherException
if the ciphertext or key is null white space or empty.
CipherException
The CipherException
class represents an exception that occurred during encryption or decryption.
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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | 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.1
- 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.0 | 458 | 2/23/2023 |