-
Notifications
You must be signed in to change notification settings - Fork 13
/
SymmetricProviderFactory.cs
61 lines (60 loc) · 2.11 KB
/
SymmetricProviderFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Text;
using Vive.Crypto.Core.Internals.Extensions;
namespace Vive.Crypto
{
/// <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>
internal sealed class SymmetricProviderFactory
{
public static ISymmetricProvider Create(string providerTypestr = "SM4")
{
var providerType = providerTypestr.ToEnum<SymmetricProviderType>();
return Create(providerType);
}
public static ISymmetricProvider Create(SymmetricProviderType providerType = SymmetricProviderType.SM4)
{
switch (providerType)
{
case SymmetricProviderType.AES128:
return new AESEncryptionL128();
case SymmetricProviderType.AES192:
return new AESEncryptionL192();
case SymmetricProviderType.AES256:
return new AESEncryptionL256();
case SymmetricProviderType.DES:
return new DESEncryption();
case SymmetricProviderType.SM4JAVA:
return new SM4ForJavaEncryption();
case SymmetricProviderType.SM4:
return new SM4Encryption();
case SymmetricProviderType.SM4JS:
return new SM4ForJSEncryption();
case SymmetricProviderType.TripleDES128:
return new TripleDESEncryptionL128();
case SymmetricProviderType.TripleDES192:
return new TripleDESEncryptionL192();
default:
return new SM4ForJSEncryption();
}
}
}
}