RuoVea.SM
10.0.0.3
See the version list below for details.
dotnet add package RuoVea.SM --version 10.0.0.3
NuGet\Install-Package RuoVea.SM -Version 10.0.0.3
<PackageReference Include="RuoVea.SM" Version="10.0.0.3" />
<PackageVersion Include="RuoVea.SM" Version="10.0.0.3" />
<PackageReference Include="RuoVea.SM" />
paket add RuoVea.SM --version 10.0.0.3
#r "nuget: RuoVea.SM, 10.0.0.3"
#:package RuoVea.SM@10.0.0.3
#addin nuget:?package=RuoVea.SM&version=10.0.0.3
#tool nuget:?package=RuoVea.SM&version=10.0.0.3
RuoVea.ExCrypt
介绍
国密 SM2 SM3 SM4 加密算法、字符串加密拓展
使用示例
1. SM2 非对称加密示例
// 生成SM2密钥对
var (publicKey, privateKey) = SMEncryption.SM2GenerateKeyPair();
Console.WriteLine($"公钥: {publicKey}");
Console.WriteLine($"私钥: {privateKey}");
// SM2加密
string plainText = "Hello, SM2加密测试!";
string encrypted = SMEncryption.SM2Encrypt(plainText, publicKey);
Console.WriteLine($"加密结果: {encrypted}");
// SM2解密
string decrypted = SMEncryption.SM2Decrypt(encrypted, privateKey);
Console.WriteLine($"解密结果: {decrypted}");
2. SM3 哈希算法示例
// SM3哈希计算
string data = "Hello, SM3哈希测试!";
string hash = SMEncryption.SM3Hash(data);
Console.WriteLine($"SM3哈希值: {hash}");
// 验证哈希
bool isValid = SMEncryption.SM3Verify(data, hash);
Console.WriteLine($"哈希验证结果: {isValid}");
3. SM4 对称加密示例
// 生成SM4密钥和IV
string sm4Key = SMEncryption.SM4GenerateKey(true); // 16进制格式
string sm4IV = SMEncryption.SM4GenerateIV(true); // 16进制格式
Console.WriteLine($"SM4密钥: {sm4Key}");
Console.WriteLine($"SM4 IV: {sm4IV}");
// SM4 ECB模式加密解密
string text = "Hello, SM4 ECB模式测试!";
string ecbEncrypted = SMEncryption.SM4EncryptECB(text, sm4Key, true);
Console.WriteLine($"ECB加密结果: {ecbEncrypted}");
string ecbDecrypted = SMEncryption.SM4DecryptECB(ecbEncrypted, sm4Key, true);
Console.WriteLine($"ECB解密结果: {ecbDecrypted}");
// SM4 CBC模式加密解密
string cbcEncrypted = SMEncryption.SM4EncryptCBC(text, sm4Key, sm4IV, true);
Console.WriteLine($"CBC加密结果: {cbcEncrypted}");
string cbcDecrypted = SMEncryption.SM4DecryptCBC(cbcEncrypted, sm4Key, sm4IV, true);
Console.WriteLine($"CBC解密结果: {cbcDecrypted}");
// 使用默认密钥的简化方式
string defaultEncrypted = SMEncryption.SM4EncryptECB(text);
Console.WriteLine($"默认密钥加密结果: {defaultEncrypted}");
string defaultDecrypted = SMEncryption.SM4DecryptECB(defaultEncrypted);
Console.WriteLine($"默认密钥解密结果: {defaultDecrypted}");
4. 综合使用场景示例
// 场景:使用SM2加密SM4密钥进行安全传输
// 接收方生成SM2密钥对
var (receiverPubKey, receiverPrivKey) = SMEncryption.SM2GenerateKeyPair();
// 发送方生成SM4会话密钥
string sessionKey = SMEncryption.SM4GenerateKey(true);
string sessionIV = SMEncryption.SM4GenerateIV(true);
// 发送方用SM2加密SM4密钥
string encryptedKey = SMEncryption.SM2Encrypt(sessionKey, receiverPubKey);
// 发送方用SM4加密实际数据
string sensitiveData = "这是一条敏感信息";
string encryptedData = SMEncryption.SM4EncryptCBC(sensitiveData, sessionKey, sessionIV, true);
// 接收方先解密SM4密钥
string decryptedKey = SMEncryption.SM2Decrypt(encryptedKey, receiverPrivKey);
// 接收方再用SM4解密数据
string finalData = SMEncryption.SM4DecryptCBC(encryptedData, decryptedKey, sessionIV, true);
Console.WriteLine($"最终解密结果: {finalData}");
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Portable.BouncyCastle (>= 1.9.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on RuoVea.SM:
| Package | Downloads |
|---|---|
|
RuoVea.ExSugar
Sqlsugar扩展 快速注入,支持简体中文、繁体中文、粤语、日语、法语、英语.使用方式:service.AddSqlsugar();继承RestFulLog 重写异常日志,操作日志,差异日志 |
|
|
RuoVea.ExPws
集成加密工具类 AES、 Base64、DESC、HMACSHA1、HMACSHA256、HMACSHA384、HMACSHA512、MD5、JsMD5、RSA、SHA1、SHA256、SHA384、、SHA512 加密算法;字符串加密拓展 ToMD5Encrypt、ToAESEncrypt、ToAESDecrypt、ToDESCEncrypt、ToDESCDecrypt、ToRSAEncrpyt、ToRSADecrypt,支持简体中文、繁体中文、粤语、日语、法语、英语. |
|
|
RuoVea.KM
RuoVea.KM 提供完整的授权管理系统: - **LicenseInfo**:授权信息实体类,包含授权ID、客户名称、绑定机器指纹、有效期等属性 - **LicenseManager**:授权管理通用类,提供授权码生成、验证、激活等功能 - **MachineFingerprint**:机器硬件指纹生成器,基于CPU、硬盘、MAC地址和主板序列号 该库提供了简单易用的 API 接口,支持 .NET 5/6/7/8/9/10,适用于各种国密加密和授权管理场景 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0.4 | 83 | 4/8/2026 |
| 10.0.0.3 | 84 | 4/1/2026 |
| 10.0.0.2 | 266 | 3/22/2026 |
| 10.0.0.1 | 784 | 7/25/2025 |
| 9.0.0.3 | 88 | 4/8/2026 |
| 9.0.0.2 | 86 | 4/1/2026 |
| 9.0.0.1 | 85 | 3/22/2026 |
| 9.0.0 | 1,138 | 7/25/2025 |
| 8.0.0.4 | 85 | 4/8/2026 |
| 8.0.0.3 | 91 | 4/1/2026 |
| 8.0.0.2 | 603 | 3/22/2026 |
| 7.0.0.4 | 88 | 4/8/2026 |
| 7.0.0.3 | 82 | 4/1/2026 |
| 7.0.0.2 | 688 | 3/23/2026 |
| 6.0.1.5 | 90 | 4/8/2026 |
| 6.0.1.4 | 80 | 4/1/2026 |
| 6.0.1.3 | 802 | 3/23/2026 |
| 5.0.0.4 | 77 | 4/8/2026 |
| 5.0.0.3 | 83 | 4/1/2026 |
| 5.0.0.2 | 136 | 3/23/2026 |