![]() |
VOOZH | about |
dotnet add package Vive.Crypto --version 1.2.4
NuGet\Install-Package Vive.Crypto -Version 1.2.4
<PackageReference Include="Vive.Crypto" Version="1.2.4" />
<PackageVersion Include="Vive.Crypto" Version="1.2.4" />Directory.Packages.props
<PackageReference Include="Vive.Crypto" />Project file
paket add Vive.Crypto --version 1.2.4
#r "nuget: Vive.Crypto, 1.2.4"
#:package Vive.Crypto@1.2.4
#addin nuget:?package=Vive.Crypto&version=1.2.4Install as a Cake Addin
#tool nuget:?package=Vive.Crypto&version=1.2.4Install as a Cake Tool
Vive.Crypto对各种常用的加密算法进行封装,有 Base64、对称加密(DES、3DES、AES、SM4)、非对称加密(RSA、SM2)、Hash(MD4、MD5、HMAC、HMAC-MD5、HMAC-SHA1、HMAC-SHA256、HMAC-SHA384、HMAC-SHA512、SHA、SHA1、SHA256、SHA384、SHA512、SM3)等实现。
内含Java(https://github.com/stoneson/Vive.Crypto/tree/master/SMCrypto/SMJAVA) 和 js(https://github.com/stoneson/Vive.Crypto/tree/master/SMCrypto/SMJS) 的SM2,SM3,SM4 密码类; 实现了C#、Java 和 JS 的SM3,SM4的相互加密解密
/// <summary> /// 哈希加密类型 /// </summary> public enum HashingProviderType { HMACMD5 = 1, HMACSHA1 = 2, HMACSHA256 = 3, HMACSHA384 = 4, HMACSHA512 = 5, MD4 = 6, MD5 = 7, SHA1 = 8, SHA256 = 9, SHA384 = 10, SHA512 = 11, SM3 = 12, }
/// <summary>
/// 非对称加密类型
/// </summary>
public enum AsymmetricProviderType
{
RSA = 1,
RSA2 = 2,
SM2 = 3,
}
/// <summary>
/// 对称加密类型
/// </summary>
public enum SymmetricProviderType
{
AES128 = 1,
AES192 = 2,
AES256 = 3,
DES = 4,
TripleDES128 = 5,
TripleDES192 = 6,
SM4 = 7,
SM4JAVA = 8,
SM4JS = 9
}
所有加密方式创建都通过下面的类来处理,只要传相应的加密方式类型名称进去就行:
/// <summary>
/// 所有加密创建工厂
/// </summary>
public sealed class CryptoFactory
{
/// <summary>
/// 创建哈希加密提供程序
/// </summary>
/// <param name="providerTypestr"></param>
/// <returns></returns>
public static IHashingProvider CreateHashing(string providerTypestr = "SHA256")
{
return HashingProviderFactory.Create(providerTypestr);
}
/// <summary>
/// 创建哈希加密提供程序
/// </summary>
/// <param name="providerType"></param>
/// <returns></returns>
public static IHashingProvider CreateHashing(HashingProviderType providerType = HashingProviderType.SHA256)
{
return HashingProviderFactory.Create(providerType);
}
//---------------------------------------------------------------------------------------------------------------------
/// <summary>
/// 创建非对称加密提供程序
/// </summary>
/// <param name="providerTypestr"></param>
/// <returns></returns>
public static IAsymmetricProvider CreateAsymmetric(string providerTypestr = "RSA")
{
return AsymmetricProviderFactory.Create(providerTypestr);
}
/// <summary>
/// 创建非对称加密提供程序
/// </summary>
/// <param name="providerType"></param>
/// <returns></returns>
public static IAsymmetricProvider CreateAsymmetric(AsymmetricProviderType providerType = AsymmetricProviderType.RSA)
{
return AsymmetricProviderFactory.Create(providerType);
}
//---------------------------------------------------------------------------------------------------------------------
/// <summary>
/// 创建对称加密提供程序
/// </summary>
/// <param name="providerTypestr"></param>
/// <returns></returns>
public static ISymmetricProvider CreateSymmetric(string providerTypestr = "SM4")
{
return SymmetricProviderFactory.Create(providerTypestr);
}
/// <summary>
/// 创建对称加密提供程序
/// </summary>
/// <param name="providerType"></param>
/// <returns></returns>
public static ISymmetricProvider CreateSymmetric(SymmetricProviderType providerType = SymmetricProviderType.SM4)
{
return SymmetricProviderFactory.Create(providerType);
}
}
国密算法参考: java:https://github.com/hyfree/SM2_SM3_SM4Encrypt/tree/5e7ec1b2604ae9471dc0baaafb45d07563576e9d JS:https://github.com/yazhouZhang/SM2-SM3-SM4-SM9 C#:https://www.cnblogs.com/shenblogs/p/10346009.html 其他加密参考: https://github.com/bing-framework/Bing.Encryption
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 is compatible. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net40 net40 is compatible. net403 net403 was computed. net45 net45 was computed. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 is compatible. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on Vive.Crypto:
| Package | Downloads |
|---|---|
|
TxSoft.Framework
Package Description |
|
|
Tx.Framework
Package Description |
This package is not used by any popular GitHub repositories.
Vive.Crypto以MIT开源发布,可随意使用