Aoxe.Cryptography 2024.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Aoxe.Cryptography --version 2024.2.1                
NuGet\Install-Package Aoxe.Cryptography -Version 2024.2.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aoxe.Cryptography" Version="2024.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aoxe.Cryptography --version 2024.2.1                
#r "nuget: Aoxe.Cryptography, 2024.2.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Aoxe.Cryptography as a Cake Addin
#addin nuget:?package=Aoxe.Cryptography&version=2024.2.1

// Install Aoxe.Cryptography as a Cake Tool
#tool nuget:?package=Aoxe.Cryptography&version=2024.2.1                

Aoxe.Cryptography

English | 简体中文


Provide an easy way to use encryption algorithms. This package support the wraps and extension methods of AES/MD5/SHA/RSA/DSA/ECDSA/DES/TripleDES

  • Symmetric Algorithm
    • AES
    • DES
    • RC2
    • TripleDES
  • Asymmetric Algorithm
    • DSA
    • ECDSA
    • RSA
  • Hash Algorithm
    • MD5
    • SHA1
    • SHA256
    • SHA384
    • SHA512

1. Quick Start

1.1. Install Package

PM> Install-Package Aoxe.Cryptography

1.2. MD5

var apple = "apple";
var md5String = apple.ToMd5String();
var md5Bytes = apple.ToMd5();

1.3. SHA

var apple = "apple";
//D0BE2DC421BE4FCD0172E5AFCEEA3970E2F3D940
var sha1String = apple.ToSha1String();
var sha1Bytes = apple.ToSha1();
//3A7BD3E2360A3D29EEA436FCFB7E44C735D117C42D1C1835420B6B9942DD4F1B
var sha256String = apple.ToSha256String();
var sha256Bytes = apple.ToSha256();
//3D8786FCB588C93348756C6429717DC6C374A14F7029362281A3B21DC10250DDF0D0578052749822EB08BC0DC1E68B0F
var sha384String = apple.ToSha384String();
var sha384Bytes = apple.ToSha384();
//844D8779103B94C18F4AA4CC0C3B4474058580A991FBA85D3CA698A0BC9E52C5940FEB7A65A3A290E17E6B23EE943ECC4F73E7490327245B4FE5D5EFB590FEB2
var sha512String = apple.ToSha512String();
var sha512Bytes = apple.ToSha512();

1.4. AES

var original = "Here is some data to encrypt!";
var key = AesHelper.GenerateKey();
var vector = AesHelper.GenerateVector();
//Default cipher mode is CBC and padding mode is PKCS7.
var encrypt = original.EncryptByAes(key, vector); // Also you can use Helper like this: AesHelper.Decrypt(encrypt, key, vector);
var decrypt = encrypt.DecryptByAes(key, vector); // Also you can use Helper like this: AesHelper.Decrypt(encrypt, key, vector);
var decryptString = Encoding.UTF8.GetString(decrypt);

1.5. RC2

var original = "Here is some data to encrypt!";
var key = Rc2Helper.GenerateKey();
var vector = Rc2Helper.GenerateVector();
//Default cipher mode is CBC and padding mode is PKCS7.
var encrypt = original.EncryptByRc2(key, vector); // Also you can use Helper like this: Rc2Helper.Decrypt(encrypt, key, vector);
var decrypt = encrypt.DecryptByRc2(key, vector); // Also you can use Helper like this: Rc2Helper.Decrypt(encrypt, key, vector);
var decryptString = Encoding.UTF8.GetString(decrypt);

1.6. DES

var original = "Here is some data to encrypt!";
var key = DesHelper.GenerateKey();
var vector = DesHelper.GenerateVector();
//Default cipher mode is CBC and padding mode is PKCS7.
var encrypt = original.EncryptByDes(key, vector); // Also you can use Helper like this: DesHelper.Decrypt(encrypt, key, vector);
var decrypt = encrypt.DecryptByDes(key, vector); // Also you can use Helper like this: DesHelper.Decrypt(encrypt, key, vector);
var decryptString = Encoding.UTF8.GetString(decrypt);

1.7. TripleDES

var original = "Here is some data to encrypt!";
var key = TripleDesHelper.GenerateKey();
var vector = TripleDesHelper.GenerateVector();
//Default cipher mode is CBC and padding mode is PKCS7.
var encrypt = original.EncryptByTripleDes(key, vector); // Also you can use Helper like this: TripleDesHelper.Decrypt(encrypt, key, vector);
var decrypt = encrypt.DecryptByTripleDes(key, vector); // Also you can use Helper like this: TripleDesHelper.Decrypt(encrypt, key, vector);
var decryptString = Encoding.UTF8.GetString(decrypt);

1.8. RSA

The default padding is OaepSHA256 and the default encoding is utf8.

var original = "Here is some data to encrypt!";
var (privateKey, publicKey) = RsaHelper.GenerateParameters();
var originalBytes = Encoding.UTF8.GetBytes(original);
var encryptBytes = originalBytes.EncryptByRsa(publicKey); // Also you can use Helper like this: RsaHelper.Encrypt(originalBytes, publicKey);
var decryptBytes = encryptBytes.DecryptByRsa(privateKey); // Also you can use Helper like this: RsaHelper.Decrypt(encryptBytes, privateKey);
var decrypt = Encoding.UTF8.GetString(decryptBytes);
Assert.True(original, decrypt);

1.9. ECDSA

The default encoding is utf8.

var original = "Here is some data to encrypt!";
//SignData
var (privateKey, publicKey) = EcdsaHelper.GenerateParameters();
var originalBytes = EcdsaHelper.Encoding.GetBytes(original);
var signBytes = originalBytes.SignDataByEcdsa(privateKey, hashAlgorithm);
//True
var result = originalBytes.VerifyDataByEcdsa(signBytes, publicKey, hashAlgorithm);
//SignHash
var (privateKey, publicKey) = EcdsaHelper.GenerateParameters();
var originalBytes = EcdsaHelper.Encoding.GetBytes(original);
var signBytes = originalBytes.SignHashByEcdsa(privateKey);
//True
var result = originalBytes.VerifyHashByEcdsa(signBytes, publicKey);

1.10. DSA

The default encoding is utf8.

var (privateKey, publicKey) = DsaHelper.GenerateParameters();
var originalBytes = DsaHelper.Encoding.GetBytes(original);
var signature = originalBytes.CreateSignatureByDsa(privateKey);
//True
var result = originalBytes.VerifySignatureByDsa(signature, publicKey);

Thank`s for JetBrains for the great support in providing assistance and user-friendly environment for my open source projects.

JetBrains

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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.  net9.0 is compatible. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2025.3.0 76 11/16/2024
2025.2.0 67 11/16/2024
2025.1.0 77 11/15/2024
2024.4.0 86 11/5/2024
2024.3.0 98 10/6/2024
2024.2.1 107 9/5/2024
2024.2.0 108 8/28/2024
2024.1.4 93 9/5/2024
2024.1.2 96 7/18/2024
2024.1.1 120 6/10/2024