remove unncessary sha1 dictionary, use new notification management
This commit is contained in:
@@ -7,11 +7,9 @@ public static class Crypto
|
||||
{
|
||||
#pragma warning disable SYSLIB0021 // Type or member is obsolete
|
||||
|
||||
private static readonly Dictionary<string, string> _hashListSHA1 = new(StringComparer.Ordinal);
|
||||
private static readonly Dictionary<(string, ushort), string> _hashListPlayersSHA256 = new();
|
||||
private static readonly Dictionary<string, string> _hashListSHA256 = new(StringComparer.Ordinal);
|
||||
private static readonly SHA256CryptoServiceProvider _sha256CryptoProvider = new();
|
||||
private static readonly SHA1CryptoServiceProvider _sha1CryptoProvider = new();
|
||||
|
||||
public static string GetFileHash(this string filePath)
|
||||
{
|
||||
@@ -19,11 +17,6 @@ public static class Crypto
|
||||
return BitConverter.ToString(cryptoProvider.ComputeHash(File.ReadAllBytes(filePath))).Replace("-", "", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static string GetHash(this string stringToHash)
|
||||
{
|
||||
return GetOrComputeHashSHA1(stringToHash);
|
||||
}
|
||||
|
||||
public static string GetHash256(this (string, ushort) playerToHash)
|
||||
{
|
||||
if (_hashListPlayersSHA256.TryGetValue(playerToHash, out var hash))
|
||||
@@ -46,14 +39,5 @@ public static class Crypto
|
||||
return _hashListSHA256[stringToCompute] =
|
||||
BitConverter.ToString(_sha256CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(stringToCompute))).Replace("-", "", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private static string GetOrComputeHashSHA1(string stringToCompute)
|
||||
{
|
||||
if (_hashListSHA1.TryGetValue(stringToCompute, out var hash))
|
||||
return hash;
|
||||
|
||||
return _hashListSHA1[stringToCompute] =
|
||||
BitConverter.ToString(_sha1CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(stringToCompute))).Replace("-", "", StringComparison.Ordinal);
|
||||
}
|
||||
#pragma warning restore SYSLIB0021 // Type or member is obsolete
|
||||
}
|
||||
Reference in New Issue
Block a user