Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HashAlgorithmNames.cs
Go to the documentation of this file.
1using System;
4
6
7internal 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
46 {
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}
static string ToUpper(string hashAlgorithName)
static readonly HashSet< string > s_allNames
static string ToAlgorithmName(this HashAlgorithm hashAlgorithm)
void Add(TKey key, TValue value)
static StringComparer OrdinalIgnoreCase