Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HashAlgorithmNames.cs
Go to the documentation of this file.
1
using
System
;
2
using
System.Collections.Generic
;
3
using
System.Security.Cryptography
;
4
5
namespace
Internal.Cryptography
;
6
7
internal
static
class
HashAlgorithmNames
8
{
9
private
static
readonly
HashSet<string>
s_allNames
=
CreateAllNames
();
10
11
public
static
string
ToAlgorithmName
(
this
HashAlgorithm
hashAlgorithm)
12
{
13
if
(hashAlgorithm
is
SHA1
)
14
{
15
return
"SHA1"
;
16
}
17
if
(hashAlgorithm
is
SHA256
)
18
{
19
return
"SHA256"
;
20
}
21
if
(hashAlgorithm
is
SHA384
)
22
{
23
return
"SHA384"
;
24
}
25
if
(hashAlgorithm
is
SHA512
)
26
{
27
return
"SHA512"
;
28
}
29
if
(hashAlgorithm
is
MD5
)
30
{
31
return
"MD5"
;
32
}
33
return
hashAlgorithm.ToString();
34
}
35
36
public
static
string
ToUpper
(
string
hashAlgorithName
)
37
{
38
if
(
s_allNames
.Contains(
hashAlgorithName
))
39
{
40
return
hashAlgorithName
.ToUpperInvariant();
41
}
42
return
hashAlgorithName
;
43
}
44
45
private
static
HashSet<string>
CreateAllNames
()
46
{
47
HashSet<string>
hashSet
=
new
HashSet<string>
(
StringComparer
.
OrdinalIgnoreCase
);
48
hashSet
.
Add
(
"SHA1"
);
49
hashSet
.
Add
(
"SHA256"
);
50
hashSet
.
Add
(
"SHA384"
);
51
hashSet
.
Add
(
"SHA512"
);
52
hashSet
.
Add
(
"MD5"
);
53
return
hashSet
;
54
}
55
}
Internal.Cryptography.HashAlgorithmNames.ToUpper
static string ToUpper(string hashAlgorithName)
Definition
HashAlgorithmNames.cs:36
Internal.Cryptography.HashAlgorithmNames.s_allNames
static readonly HashSet< string > s_allNames
Definition
HashAlgorithmNames.cs:9
Internal.Cryptography.HashAlgorithmNames.CreateAllNames
static HashSet< string > CreateAllNames()
Definition
HashAlgorithmNames.cs:45
Internal.Cryptography.HashAlgorithmNames.ToAlgorithmName
static string ToAlgorithmName(this HashAlgorithm hashAlgorithm)
Definition
HashAlgorithmNames.cs:11
Internal.Cryptography.HashAlgorithmNames
Definition
HashAlgorithmNames.cs:8
System.Collections.Generic.Dictionary.Add
void Add(TKey key, TValue value)
Definition
Dictionary.cs:873
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Security.Cryptography.HashAlgorithm
Definition
HashAlgorithm.cs:10
System.Security.Cryptography.MD5
Definition
MD5.cs:9
System.Security.Cryptography.SHA1
Definition
SHA1.cs:7
System.Security.Cryptography.SHA256
Definition
SHA256.cs:7
System.Security.Cryptography.SHA384
Definition
SHA384.cs:7
System.Security.Cryptography.SHA512
Definition
SHA512.cs:7
System.StringComparer.OrdinalIgnoreCase
static StringComparer OrdinalIgnoreCase
Definition
StringComparer.cs:23
System.StringComparer
Definition
StringComparer.cs:12
Internal.Cryptography
Definition
AesBCryptModes.cs:5
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Security.Cryptography
Definition
CryptoPool.cs:3
System
Definition
BlockingCollection.cs:8
source
System.Security.Cryptography.Algorithms
Internal.Cryptography
HashAlgorithmNames.cs
Generated by
1.10.0