-
Notifications
You must be signed in to change notification settings - Fork 1
/
VerifySignOption.cs
96 lines (78 loc) · 2.32 KB
/
VerifySignOption.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
namespace NetPro.Sign
{
public class VerifySignOption
{
public VerifySignOption()
{
}
public bool IsDebug { get; set; }
public bool IsForce { get; set; }
public bool Enabled { get; set; }
public int ExpireSeconds { get; set; } = 5;
public DeclareCommonParameters CommonParameters { get; set; }
public List<Type> OperationFilterDescriptors { get; set; } = new List<Type>();
}
public class DeclareCommonParameters
{
public string TimestampName { get; set; } = "timestamp";
public string AppIdName { get; set; } = "appid";
public string SignName { get; set; } = "sign";
public string EncryptFlag { get; set; } = "encryptflag";
}
public static class VerifySignOptionsExtensions
{
public static void OperationFilter<TFilter>(this VerifySignOption verifySignOption) where TFilter : IOperationFilter
{
verifySignOption.OperationFilterDescriptors.Add(typeof(TFilter));
}
}
/// <summary>
/// 签名加密
/// </summary>
[Flags]
public enum EncryptEnum
{
/// <summary>
/// Dafault 默认(签名默认HMACSHA256;脱敏默认不加密)
/// </summary>
Default = 0,
/// <summary>
/// 签名SHA256算法
/// <remarks></remarks>
/// </summary>
SignSHA256 = 1,
/// <summary>
/// 签名MD5算法
/// <remarks>
/// </remarks>
/// </summary>
/// <remarks>
/// <![CDATA[ 1<<1]]>
/// </remarks>
SignMD5 = 2,
/// <summary>
/// 脱敏AES
/// <remarks></remarks>
/// </summary>
/// <remarks> <![CDATA[ 1<<2]]></remarks>
SymmetricAES = 4,
/// <summary>
/// 脱敏DES
/// <remarks> <![CDATA[ 1<<3]]></remarks>
/// </summary>
SymmetricDES = 8,
/// <summary>
/// 脱敏Base64
/// <remarks> <![CDATA[ 1<<4]]></remarks>
/// </summary>
/// <remarks>2^2;2^3</remarks>
SymmetricBase64 = 16,
/// <summary>
/// 签名HMACSHA256算法
/// <remarks> <![CDATA[ 1<<5]]></remarks>
/// </summary>
SignHMACSHA256 = 32,
}
}