RuoVea.ExCrypt 2.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package RuoVea.ExCrypt --version 2.1.1
NuGet\Install-Package RuoVea.ExCrypt -Version 2.1.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="RuoVea.ExCrypt" Version="2.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RuoVea.ExCrypt --version 2.1.1
#r "nuget: RuoVea.ExCrypt, 2.1.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 RuoVea.ExCrypt as a Cake Addin
#addin nuget:?package=RuoVea.ExCrypt&version=2.1.1

// Install RuoVea.ExCrypt as a Cake Tool
#tool nuget:?package=RuoVea.ExCrypt&version=2.1.1

RuoVea.ExCrypt

介绍

集成加密工具类 AES、 Base64、DESC、HMACSHA1、HMACSHA256、HMACSHA384、HMACSHA512、MD5、JsMD5、RSA、SHA1、SHA256、SHA384、、SHA512 加密算法; 字符串加密拓展 ToMD5Encrypt、ToAESEncrypt、ToAESDecrypt、ToDESCEncrypt、ToDESCDecrypt、ToRSAEncrpyt、ToRSADecrypt

使用示例
var aesKey = AESCrypt.CreateAesKey();
var key = aesKey.Key;
var iv = aesKey.IV;

/*
var _max = 10000;

var s1 = Stopwatch.StartNew();

for (int i = 0; i < _max; i++)
{
    aesKey = EncryptProvider.CreateAesKey();
}
s1.Stop();

var s2 = Stopwatch.StartNew();
for (int i = 0; i < _max; i++)
{
    aesKey = EncryptProvider.CreateAesKey(false);
}
s2.Stop();

Console.WriteLine(((double)(s1.Elapsed.TotalMilliseconds * 1000000) / _max).ToString("0.00 ns"));
Console.WriteLine(((double)(s2.Elapsed.TotalMilliseconds * 1000000) / _max).ToString("0.00 ns"));
Console.Read();
*/

var plaintext = "Hello world 123456789/*-+!@#$%^&*()-=_+";
var encrypted = AESCrypt.AESEncrypt(plaintext, key, iv);
var decrypted = AESCrypt.AESDecrypt(encrypted, key, iv);

Console.WriteLine("Plaintext to encrypt: " + plaintext);
Console.WriteLine();

Console.WriteLine("** AES SecureRandom **");
Console.WriteLine("Encrypted " + " (Length: " + encrypted.Length + ") " + encrypted);
Console.WriteLine("Decrypted " + " (Length: " + decrypted.Length + ") " + decrypted);
Console.WriteLine("Key: {0} IV: {1}", key, iv);

Console.WriteLine();
Console.WriteLine("** AES SecureRandom with Byte input/output **");
byte[] bencrypted = AESCrypt.AESEncrypt(Encoding.UTF8.GetBytes(plaintext), key, iv);
byte[] bdecrypted = AESCrypt.AESDecrypt(bencrypted, key, iv);

Console.WriteLine("Encrypted " + " (Length: " + bencrypted.Length + ") " + Encoding.UTF8.GetString(bencrypted));
Console.WriteLine("Decrypted " + " (Length: " + bdecrypted.Length + ") " + Encoding.UTF8.GetString(bdecrypted));
Console.WriteLine("Key: {0} IV: {1}", key, iv);

Console.WriteLine();

Console.WriteLine("** AES Non-SecureRandom **");

aesKey = AESCrypt.CreateAesKey();
key = aesKey.Key;
iv = aesKey.IV;

encrypted = AESCrypt.AESEncrypt(plaintext, key, iv);
decrypted = AESCrypt.AESDecrypt(encrypted, key, iv);
Console.WriteLine("Encrypted " + " (Length: " + encrypted.Length + ") " + encrypted);
Console.WriteLine("Decrypted " + " (Length: " + decrypted.Length + ") " + decrypted);
Console.WriteLine("Key: {0} IV: {1}", key, iv);

Console.WriteLine();
Console.WriteLine("** RSA **");
var rsaKey = RSACrypt.GenerateSecretKey();

var publicKey = rsaKey.publicKey;
var privateKey = rsaKey.privateKey;
////var exponent = rsaKey.Exponent;
////var modulus = rsaKey.Modulus;

//encrypted = RSACrypt.RSAEncrypt(publicKey, plaintext);

//encrypted = RSACrypt.RSAEncrypt(publicKey, plaintext, RSACrypt.Pkcs1);
//decrypted = RSACrypt.RSADecrypt(privateKey, encrypted, RSACrypt..Pkcs1);


//Console.WriteLine("Encrypted: " + encrypted);
//Console.WriteLine("Decrypted: " + decrypted);
//Console.WriteLine("publicKey: {0} privateKey: {1}", publicKey, privateKey);

Console.WriteLine();
Console.WriteLine("** SHA **");
Console.WriteLine("SHA1: " + SHA1Crypt.Encrypt(plaintext));
Console.WriteLine("SHA256: " +  SHA256Crypt.Encrypt(plaintext));
Console.WriteLine("SHA384: " +  SHA384Crypt.Encrypt(plaintext));
Console.WriteLine("SHA512: " +  SHA512Crypt.Encrypt(plaintext));


Console.WriteLine();
Console.WriteLine("** Test issues #25  https://github.com/myloveCc/NETCore.Encrypt/issues/25 **");

//rsaKey = EncryptProvider.CreateRsaKey();

//publicKey = rsaKey.PublicKey;
//privateKey = rsaKey.PrivateKey;

var testStr = "test issues #25 ";

//Console.WriteLine($"Test str:{testStr}");

var saveDir = AppDomain.CurrentDomain.BaseDirectory;

//save public key
var publicKeySavePath = Path.Combine(saveDir, "privateKey.txt");
if (File.Exists(publicKeySavePath))
{
    File.Delete(publicKeySavePath);
}
using (FileStream fs = new FileStream(publicKeySavePath, FileMode.CreateNew))
{
    fs.Write(Encoding.UTF8.GetBytes(privateKey));
}

//save encrypt text
var encryptStr =RSACrypt.Encrypt(testStr, publicKey);
Console.WriteLine($"encryped str:{encryptStr}");
var encryptSavePath = Path.Combine(saveDir, "encrypt.txt");

if (File.Exists(encryptSavePath))
{
    File.Delete(encryptSavePath);
}

using (FileStream fs = new FileStream(encryptSavePath, FileMode.CreateNew))
{
    fs.Write(Encoding.UTF8.GetBytes(encryptStr));
}

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.7.1

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETFramework 4.8.1

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RuoVea.ExCrypt:

Package Downloads
RuoVea.ExFilter

注入 进行全局的异常日志收集、执行操作日志、参数验证 services.ExceptionSetup();// 注入 全局错误日志处 services.ExceptionSetup(ExceptionLog actionOptions);// 注入 全局错误日志处 services.ExceptionSetup(builder.Configuration.GetSection("AopOption:ExceptionLog"));// 注入 全局错误日志处 services.RequestActionSetup();// 注入 请求日志拦截 [执行操作日志、参数验证 ] services.RequestActionSetup(RequestLog actionOptions);// 注入 请求日志拦截 [执行操作日志、参数验证 ] services.RequestActionSetup(builder.Configuration.GetSection("AopOption:RequestLog"));// 注入 请求日志拦截 [执行操作日志、参数验证 ] services.ResourceSetup();//对资源型信息进行过滤 services.ResultSetup();//对结果进行统一 services.ApISafeSetup(AppSign actionOptions);//接口安全校验 services.ApISafeSetup(builder.Configuration.GetSection("AopOption:AppSign"));//接口安全校验 services.ApISignSetup(AppSign actionOptions);//签名验证 ( appKey + signKey + timeStamp + data ); services.ApISignSetup(builder.Configuration.GetSection("AopOption:AppSign"));//签名验证 ( appKey + signKey + timeStamp + data ); services.AddValidateSetup();//模型校验 services.AddUiFilesZipSetup();//将前端UI压缩文件进行解压 不进行接口安全校验 -> NonAplSafeAttribute 不签名验证 -> NonAplSignAttribute 不进行全局的异常日志收集 -> NonExceptionAttribute 不对资源型信息进行过滤 -> NonResourceAttribute 不对结果进行统一 -> NonRestfulResultAttribute

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 194 11/23/2023
6.0.2 914 9/16/2022
6.0.1 366 8/24/2022
6.0.0 1,793 2/9/2022
5.0.7.1 97 11/23/2023
5.0.7 675 11/13/2021
5.0.6 374 11/5/2021
5.0.5 302 11/4/2021
5.0.4 330 11/4/2021
5.0.3 305 10/5/2021
5.0.2 309 9/30/2021
5.0.1 288 9/27/2021
5.0.0 364 9/26/2021
2.1.1 78 11/24/2023