RuoVea.SM
6.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RuoVea.SM --version 6.0.0
NuGet\Install-Package RuoVea.SM -Version 6.0.0
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.SM" Version="6.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RuoVea.SM --version 6.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RuoVea.SM, 6.0.0"
#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.SM as a Cake Addin #addin nuget:?package=RuoVea.SM&version=6.0.0 // Install RuoVea.SM as a Cake Tool #tool nuget:?package=RuoVea.SM&version=6.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RuoVea.ExCrypt
介绍
国密 SM2 SM3 SM4 加密算法、字符串加密拓展
使用示例
/// <summary>
/// SM2 获取秘钥方法
/// </summary>
/// <returns></returns>
public static string SM2GetKey()
{
string priKey = string.Empty;
string pubkey = string.Empty;
var strkey = SM2Util.GenerateKeyPair();
pubkey = strkey[0].ToUpper().ToString();
priKey = strkey[1].ToUpper().ToString();
return "pubKey:" + pubkey + "\r\n" + "priKey:" + priKey;
}
/// <summary>
/// SM2 获取秘钥方法
/// </summary>
/// <returns>pubKey,priKey</returns>
public static (string,string) SM2Key()
{
string priKey = string.Empty;
string pubkey = string.Empty;
var strkey = SM2Util.GenerateKeyPair();
pubkey = strkey[0].ToUpper().ToString();
priKey = strkey[1].ToUpper().ToString();
return (pubkey , priKey);
}
/// <summary>
/// SM2加密 非对称
/// </summary>
/// <param name="strdata"></param>
/// <param name="pubKey"></param>
/// <returns></returns>
public static string SM2EncryptBase64(string strdata, string pubKey)
{
return SM2Util.encryptBase64(strdata, pubKey.ToLower());
}
/// <summary>
/// SM2 解密 非对称
/// </summary>
/// <param name="strdata"></param>
/// <param name="priKey"></param>
/// <returns></returns>
public static string SM2DecryptBase64(string strdata, string priKey)
{
SM2 sm2 = new SM2(priKey.ToLower(), null);
byte[] deCode = Base64.Decode(strdata);
byte[] decryptText = sm2.deceypt(deCode);
return Encoding.UTF8.GetString(decryptText);
}
/// <summary>
///
/// </summary>
/// <param name="strdata"></param>
/// <returns></returns>
public static string SM3Encrypt(string strdata)
{
return SM3Utils.Encrypt(strdata);
}
/// <summary>
/// SM4 加密 (对称)ECB
/// </summary>
/// <param name="strdata"></param>
/// <param name="Key"></param>
/// <returns></returns>
public static string SM4EncryptBase64_ECB(string strdata, string Key)
{
SM4Utils.secretKey = Key;
SM4Utils.hexString = false;
string ciphertext = SM4Utils.Encrypt_ECB(strdata);
return ciphertext;
}
/// <summary>
/// SM4 解密 (对称)ECB
/// </summary>
/// <param name="strdata"></param>
/// <param name="Key"></param>
/// <returns></returns>
public static string SM4DecryptBase64_ECB(string strdata, string Key)
{
SM4Utils.secretKey = Key;
SM4Utils.hexString = false;
string ciphertext = SM4Utils.Decrypt_ECB(strdata);
return ciphertext;
}
/// <summary>
/// SM4 加密 (对称)CBC
/// </summary>
/// <param name="strdata"></param>
/// <param name="Key"></param>
/// <param name="iv"></param>
/// <returns></returns>
public static string SM4EncryptBase64_ECB(string strdata, string Key,string iv)
{
SM4Utils.secretKey = Key;
SM4Utils.hexString = false;
SM4Utils.iv = iv;
string ciphertext = SM4Utils.Encrypt_CBC(strdata);
return ciphertext;
}
/// <summary>
/// SM4 解密 (对称)CBC
/// </summary>
/// <param name="strdata"></param>
/// <param name="Key"></param>
/// <param name="iv"></param>
/// <returns></returns>
public static string SM4DecryptBase64_ECB(string strdata, string Key, string iv)
{
SM4Utils.secretKey = Key;
SM4Utils.hexString = false;
SM4Utils.iv = iv;
string ciphertext = SM4Utils.Decrypt_CBC(strdata);
return ciphertext;
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Portable.BouncyCastle (>= 1.9.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RuoVea.SM:
Package | Downloads |
---|---|
RuoVea.ExSugar
Sqlsugar扩展 快速注入,支持简体中文、繁体中文、粤语、日语、法语、英语.使用方式:service.AddSqlsugar();继承RestFulLog 重写异常日志,操作日志,差异日志 |
GitHub repositories
This package is not used by any popular GitHub repositories.