mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Closes #2455
This commit is contained in:
parent
99569ee3fe
commit
c709d529c1
6 changed files with 8 additions and 7 deletions
|
@ -241,7 +241,7 @@ internal sealed class GlobalCache : SerializableFile {
|
|||
continue;
|
||||
}
|
||||
|
||||
string depotKey = BitConverter.ToString(depotKeyResult.DepotKey).Replace("-", "", StringComparison.Ordinal);
|
||||
string depotKey = Convert.ToHexString(depotKeyResult.DepotKey);
|
||||
|
||||
if (DepotKeys.TryGetValue(depotKeyResult.DepotID, out string? previousDepotKey) && (previousDepotKey == depotKey)) {
|
||||
continue;
|
||||
|
|
|
@ -302,7 +302,7 @@ public static class ASF {
|
|||
|
||||
byte[] responseBytes = response.Content as byte[] ?? response.Content.ToArray();
|
||||
|
||||
string checksum = BitConverter.ToString(SHA512.HashData(responseBytes)).Replace("-", "", StringComparison.Ordinal);
|
||||
string checksum = Convert.ToHexString(SHA512.HashData(responseBytes));
|
||||
|
||||
if (!checksum.Equals(remoteChecksum, StringComparison.OrdinalIgnoreCase)) {
|
||||
ArchiLogger.LogGenericError(Strings.ChecksumWrong);
|
||||
|
@ -409,9 +409,9 @@ public static class ASF {
|
|||
|
||||
if (!string.IsNullOrEmpty(Program.NetworkGroup)) {
|
||||
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
||||
networkGroupText = $"-{BitConverter.ToString(SHA256.HashData(Encoding.UTF8.GetBytes(Program.NetworkGroup!))).Replace("-", "", StringComparison.Ordinal)}";
|
||||
networkGroupText = $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(Program.NetworkGroup!)))}";
|
||||
} else if (!string.IsNullOrEmpty(GlobalConfig.WebProxyText)) {
|
||||
networkGroupText = $"-{BitConverter.ToString(SHA256.HashData(Encoding.UTF8.GetBytes(GlobalConfig.WebProxyText!))).Replace("-", "", StringComparison.Ordinal)}";
|
||||
networkGroupText = $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(GlobalConfig.WebProxyText!)))}";
|
||||
}
|
||||
|
||||
ConfirmationsSemaphore ??= await PluginsCore.GetCrossProcessSemaphore($"{nameof(ConfirmationsSemaphore)}{networkGroupText}").ConfigureAwait(false);
|
||||
|
|
|
@ -162,7 +162,7 @@ internal static class OS {
|
|||
// The only purpose of using hashing 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 will do, and the shorter the better
|
||||
string uniqueName = $"Global\\{GetOsResourceName(nameof(SingleInstance))}-{BitConverter.ToString(SHA256.HashData(Encoding.UTF8.GetBytes(Directory.GetCurrentDirectory()))).Replace("-", "", StringComparison.Ordinal)}";
|
||||
string uniqueName = $"Global\\{GetOsResourceName(nameof(SingleInstance))}-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(Directory.GetCurrentDirectory())))}";
|
||||
|
||||
Mutex? singleInstance = null;
|
||||
|
||||
|
|
|
@ -3014,7 +3014,7 @@ public sealed class Bot : IAsyncDisposable {
|
|||
|
||||
if ((callback.AvatarHash.Length > 0) && callback.AvatarHash.Any(static singleByte => singleByte != 0)) {
|
||||
#pragma warning disable CA1308 // False positive, we're intentionally converting this part to lowercase and it's not used for any security decisions based on the result of the normalization
|
||||
avatarHash = BitConverter.ToString(callback.AvatarHash).Replace("-", "", StringComparison.Ordinal).ToLowerInvariant();
|
||||
avatarHash = Convert.ToHexString(callback.AvatarHash).ToLowerInvariant();
|
||||
#pragma warning restore CA1308 // False positive, we're intentionally converting this part to lowercase and it's not used for any security decisions based on the result of the normalization
|
||||
|
||||
if (string.IsNullOrEmpty(avatarHash) || avatarHash.All(static singleChar => singleChar == '0')) {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
|
||||
<PackageReference Include="JustArchiNET.Madness" />
|
||||
<Using Include="JustArchiNET.Madness" />
|
||||
<Using Include="JustArchiNET.Madness.ConvertMadness.Convert" Alias="Convert" />
|
||||
<Using Include="JustArchiNET.Madness.EnvironmentMadness.Environment" Alias="Environment" />
|
||||
<Using Include="JustArchiNET.Madness.FileMadness.File" Alias="File" />
|
||||
<Using Include="JustArchiNET.Madness.HashCodeMadness.HashCode" Alias="HashCode" />
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
|
||||
<PackageVersion Include="JustArchiNET.Madness" Version="2.1.0" />
|
||||
<PackageVersion Include="JustArchiNET.Madness" Version="2.2.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.HttpOverrides" Version="2.2.0" />
|
||||
|
|
Loading…
Reference in a new issue