-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJwtKeyHMAC.cs
42 lines (37 loc) · 1.15 KB
/
JwtKeyHMAC.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
using System;
using System.Text;
using Jose;
namespace Bit0.Utils.Security.Jwt
{
/// <summary>
/// JsonWebToken encryption key wrapper for HMAC
/// </summary>
// ReSharper disable once InconsistentNaming
public class JwtKeyHMAC : IJwtKey
{
/// <inheritdoc />
public JwsAlgorithm Algorithm { get; set; }
/// <inheritdoc />
public Object Key => SecretKey;
/// <inheritdoc />
public Byte[] SecretKey { get; set; }
/// <summary>
/// JsonWebToken encryption key wrapper for HMAC
/// </summary>
/// <param name="key"></param>
/// <param name="algo"></param>
public JwtKeyHMAC(String key, JwsAlgorithm algo = JwsAlgorithm.HS512)
: this(Encoding.UTF8.GetBytes(key), algo)
{ }
/// <summary>
/// JsonWebToken encryption key wrapper for HMAC
/// </summary>
/// <param name="key"></param>
/// <param name="algo"></param>
public JwtKeyHMAC(Byte[] key, JwsAlgorithm algo = JwsAlgorithm.HS512)
{
Algorithm = algo;
SecretKey = key;
}
}
}