diff --git a/ArchiSteamFarm/Core/ASF.cs b/ArchiSteamFarm/Core/ASF.cs index fdfa2c8d3..b9a1346da 100644 --- a/ArchiSteamFarm/Core/ASF.cs +++ b/ArchiSteamFarm/Core/ASF.cs @@ -398,11 +398,11 @@ namespace ArchiSteamFarm.Core { string networkGroupText = ""; if (!string.IsNullOrEmpty(Program.NetworkGroup)) { - using SHA256CryptoServiceProvider hashingAlgorithm = new(); + using SHA256 hashingAlgorithm = SHA256.Create(); networkGroupText = "-" + BitConverter.ToString(hashingAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(Program.NetworkGroup!))).Replace("-", "", StringComparison.Ordinal); } else if (!string.IsNullOrEmpty(GlobalConfig.WebProxyText)) { - using SHA256CryptoServiceProvider hashingAlgorithm = new(); + using SHA256 hashingAlgorithm = SHA256.Create(); networkGroupText = "-" + BitConverter.ToString(hashingAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(GlobalConfig.WebProxyText!))).Replace("-", "", StringComparison.Ordinal); } diff --git a/ArchiSteamFarm/Core/OS.cs b/ArchiSteamFarm/Core/OS.cs index 04d008116..9f34e277e 100644 --- a/ArchiSteamFarm/Core/OS.cs +++ b/ArchiSteamFarm/Core/OS.cs @@ -106,7 +106,7 @@ namespace ArchiSteamFarm.Core { // The only purpose of using hashingAlgorithm here is to cut on a potential size of the resource name - paths can be really long, and we almost certainly have some upper limit on the resource name we can allocate // At the same time it'd be the best if we avoided all special characters, such as '/' found e.g. in base64, as we can't be sure that it's not a prohibited character in regards to native OS implementation // Because of that, SHA256 is sufficient for our case, as it generates alphanumeric characters only, and is barely 256-bit long. We don't need any kind of complex cryptography or collision detection here, any hashing algorithm will do, and the shorter the better - using (SHA256CryptoServiceProvider hashingAlgorithm = new()) { + using (SHA256 hashingAlgorithm = SHA256.Create()) { uniqueName = "Global\\" + GetOsResourceName(nameof(SingleInstance)) + "-" + BitConverter.ToString(hashingAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(Directory.GetCurrentDirectory()))).Replace("-", "", StringComparison.Ordinal); } diff --git a/ArchiSteamFarm/Steam/Bot.cs b/ArchiSteamFarm/Steam/Bot.cs index ea1d7edf4..eeea9a5f6 100644 --- a/ArchiSteamFarm/Steam/Bot.cs +++ b/ArchiSteamFarm/Steam/Bot.cs @@ -2908,9 +2908,9 @@ namespace ArchiSteamFarm.Steam { fileStream.Seek(0, SeekOrigin.Begin); #pragma warning disable CA5350 // This is actually a fair warning, but there is nothing we can do about Steam using weak cryptographic algorithms - using SHA1CryptoServiceProvider sha = new(); + using SHA1 hashingAlgorithm = SHA1.Create(); - sentryHash = await sha.ComputeHashAsync(fileStream).ConfigureAwait(false); + sentryHash = await hashingAlgorithm.ComputeHashAsync(fileStream).ConfigureAwait(false); #pragma warning restore CA5350 // This is actually a fair warning, but there is nothing we can do about Steam using weak cryptographic algorithms } } catch (Exception e) {