Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HMACMD5.cs
Go to the documentation of this file.
3
5
6[UnsupportedOSPlatform("browser")]
7public class HMACMD5 : HMAC
8{
10
11 public override byte[] Key
12 {
13 get
14 {
15 return base.Key;
16 }
17 set
18 {
19 if (value == null)
20 {
21 throw new ArgumentNullException("value");
22 }
24 base.Key = _hMacCommon.ActualKey;
25 }
26 }
27
28 public HMACMD5()
29 : this(RandomNumberGenerator.GetBytes(64))
30 {
31 }
32
33 public HMACMD5(byte[] key)
34 {
35 if (key == null)
36 {
37 throw new ArgumentNullException("key");
38 }
39 base.HashName = "MD5";
40 _hMacCommon = new HMACCommon("MD5", key, 64);
41 base.Key = _hMacCommon.ActualKey;
42 base.BlockSizeValue = 64;
44 }
45
46 protected override void HashCore(byte[] rgb, int ib, int cb)
47 {
48 _hMacCommon.AppendHashData(rgb, ib, cb);
49 }
50
51 protected override void HashCore(ReadOnlySpan<byte> source)
52 {
54 }
55
56 protected override byte[] HashFinal()
57 {
59 }
60
61 protected override bool TryHashFinal(Span<byte> destination, out int bytesWritten)
62 {
63 return _hMacCommon.TryFinalizeHashAndReset(destination, out bytesWritten);
64 }
65
66 public override void Initialize()
67 {
69 }
70
71 public static byte[] HashData(byte[] key, byte[] source)
72 {
73 if (key == null)
74 {
75 throw new ArgumentNullException("key");
76 }
77 if (source == null)
78 {
79 throw new ArgumentNullException("source");
80 }
82 }
83
85 {
86 byte[] array = new byte[16];
87 int num = HashData(key, source, array.AsSpan());
88 return array;
89 }
90
92 {
93 if (!TryHashData(key, source, destination, out var bytesWritten))
94 {
96 }
97 return bytesWritten;
98 }
99
101 {
102 if (destination.Length < 16)
103 {
104 bytesWritten = 0;
105 return false;
106 }
108 return true;
109 }
110
111 protected override void Dispose(bool disposing)
112 {
113 if (disposing)
114 {
115 HMACCommon hMacCommon = _hMacCommon;
116 if (hMacCommon != null)
117 {
118 _hMacCommon = null;
119 hMacCommon.Dispose(disposing);
120 }
121 }
122 base.Dispose(disposing);
123 }
124}
void Dispose(bool disposing)
Definition HMACCommon.cs:98
bool TryFinalizeHashAndReset(Span< byte > destination, out int bytesWritten)
Definition HMACCommon.cs:83
void AppendHashData(byte[] data, int offset, int count)
Definition HMACCommon.cs:63
static int MacData(string hashAlgorithmId, ReadOnlySpan< byte > key, ReadOnlySpan< byte > source, Span< byte > destination)
static string Argument_DestinationTooShort
Definition SR.cs:14
Definition SR.cs:7
override void HashCore(ReadOnlySpan< byte > source)
Definition HMACMD5.cs:51
static byte[] HashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source)
Definition HMACMD5.cs:84
override void Dispose(bool disposing)
Definition HMACMD5.cs:111
override bool TryHashFinal(Span< byte > destination, out int bytesWritten)
Definition HMACMD5.cs:61
static bool TryHashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source, Span< byte > destination, out int bytesWritten)
Definition HMACMD5.cs:100
override void HashCore(byte[] rgb, int ib, int cb)
Definition HMACMD5.cs:46
static int HashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source, Span< byte > destination)
Definition HMACMD5.cs:91
static byte[] HashData(byte[] key, byte[] source)
Definition HMACMD5.cs:71