Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MD5.cs
Go to the documentation of this file.
4
6
7[UnsupportedOSPlatform("browser")]
8public abstract class MD5 : HashAlgorithm
9{
10 private sealed class Implementation : MD5
11 {
12 private readonly HashProvider _hashProvider;
13
15 {
17 HashSizeValue = _hashProvider.HashSizeInBytes * 8;
18 }
19
20 protected sealed override void HashCore(byte[] array, int ibStart, int cbSize)
21 {
22 _hashProvider.AppendHashData(array, ibStart, cbSize);
23 }
24
25 protected sealed override void HashCore(ReadOnlySpan<byte> source)
26 {
28 }
29
30 protected sealed override byte[] HashFinal()
31 {
33 }
34
35 protected sealed override bool TryHashFinal(Span<byte> destination, out int bytesWritten)
36 {
37 return _hashProvider.TryFinalizeHashAndReset(destination, out bytesWritten);
38 }
39
40 public sealed override void Initialize()
41 {
43 }
44
45 protected sealed override void Dispose(bool disposing)
46 {
47 _hashProvider.Dispose(disposing);
48 base.Dispose(disposing);
49 }
50 }
51
52 protected MD5()
53 {
54 HashSizeValue = 128;
55 }
56
57 public new static MD5 Create()
58 {
59 return new Implementation();
60 }
61
62 [RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")]
63 public new static MD5? Create(string algName)
64 {
65 return (MD5)CryptoConfig.CreateFromName(algName);
66 }
67
68 public static byte[] HashData(byte[] source)
69 {
70 if (source == null)
71 {
72 throw new ArgumentNullException("source");
73 }
75 }
76
77 public static byte[] HashData(ReadOnlySpan<byte> source)
78 {
79 byte[] array = GC.AllocateUninitializedArray<byte>(16);
80 int num = HashData(source, array.AsSpan());
81 return array;
82 }
83
85 {
86 if (!TryHashData(source, destination, out var bytesWritten))
87 {
89 }
90 return bytesWritten;
91 }
92
93 public static bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten)
94 {
95 if (destination.Length < 16)
96 {
97 bytesWritten = 0;
98 return false;
99 }
101 return true;
102 }
103}
static int HashData(string hashAlgorithmId, ReadOnlySpan< byte > source, Span< byte > destination)
static HashProvider CreateHashProvider(string hashAlgorithmId)
void AppendHashData(byte[] data, int offset, int count)
bool TryFinalizeHashAndReset(Span< byte > destination, out int bytesWritten)
int FinalizeHashAndReset(Span< byte > destination)
Definition GC.cs:8
static string Argument_DestinationTooShort
Definition SR.cs:14
Definition SR.cs:7
static ? object CreateFromName(string name, params object?[]? args)
override bool TryHashFinal(Span< byte > destination, out int bytesWritten)
Definition MD5.cs:35
override void HashCore(byte[] array, int ibStart, int cbSize)
Definition MD5.cs:20
override void Dispose(bool disposing)
Definition MD5.cs:45
override void HashCore(ReadOnlySpan< byte > source)
Definition MD5.cs:25
static int HashData(ReadOnlySpan< byte > source, Span< byte > destination)
Definition MD5.cs:84
static new MD5 Create()
Definition MD5.cs:57
static byte[] HashData(ReadOnlySpan< byte > source)
Definition MD5.cs:77
static new? MD5 Create(string algName)
Definition MD5.cs:63
static byte[] HashData(byte[] source)
Definition MD5.cs:68
static bool TryHashData(ReadOnlySpan< byte > source, Span< byte > destination, out int bytesWritten)
Definition MD5.cs:93