This commit is contained in:
Archi
2023-11-14 20:01:29 +01:00
parent b34f18497d
commit f2ff2f4929
45 changed files with 156 additions and 616 deletions

View File

@@ -66,10 +66,9 @@ public static class PluginsCore {
// 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
if (!string.IsNullOrEmpty(Program.NetworkGroup)) {
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
objectName += $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(Program.NetworkGroup!)))}";
objectName += $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(Program.NetworkGroup)))}";
} else if (!string.IsNullOrEmpty(ASF.GlobalConfig.WebProxyText)) {
objectName += $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(ASF.GlobalConfig.WebProxyText!)))}";
objectName += $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(ASF.GlobalConfig.WebProxyText)))}";
}
string resourceName = OS.GetOsResourceName(objectName);