Merge branch '2.0.0' into dotnet10-api14-migration

This commit is contained in:
defnotken
2025-11-26 16:20:38 -06:00
116 changed files with 20468 additions and 3311 deletions

View File

@@ -1,4 +1,7 @@
using Blake3;
using Blake3;
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Security.Cryptography;
using System.Text;
@@ -10,9 +13,8 @@ public static class Crypto
private const int _bufferSize = 65536;
#pragma warning disable SYSLIB0021 // Type or member is obsolete
// SHA256 hash caches
private static readonly Dictionary<(string, ushort), string> _hashListPlayersSHA256 = [];
private static readonly Dictionary<string, string> _hashListSHA256 = new(StringComparer.Ordinal);
private static readonly ConcurrentDictionary<(string, ushort), string> _hashListPlayersSHA256 = new();
private static readonly ConcurrentDictionary<string, string> _hashListSHA256 = new(StringComparer.Ordinal);
private static readonly SHA256CryptoServiceProvider _sha256CryptoProvider = new();
// BLAKE3 hash caches
@@ -222,10 +224,10 @@ public static class Crypto
/// <returns>Hashed string</returns>
public static string GetHash256(this string stringToHash)
{
return GetOrComputeHashSHA256(stringToHash);
return _hashListSHA256.GetOrAdd(stringToHash, ComputeHashSHA256);
}
private static string GetOrComputeHashSHA256(string stringToCompute)
private static string ComputeHashSHA256(string stringToCompute)
{
if (_hashListSHA256.TryGetValue(stringToCompute, out var hash))
return hash;