This commit is contained in:
lanyi 2022-01-25 13:37:44 +01:00
parent 6ce486945b
commit bedc003966
2 changed files with 10 additions and 11 deletions

View File

@ -12,7 +12,7 @@ namespace HashCalculator.GUI
public string Type { get; }
public string Name { get; }
public string NameString { get; }
public IEnumerable<string> DisplayLabels { get; }
public IReadOnlyList<string> DisplayLabels { get; }
public uint InstanceId => SageHash.CalculateLowercaseHash(Name);
public string InstanceIdString => $"{InstanceId:x8} ({InstanceId,10})";

View File

@ -3,17 +3,17 @@ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
using TechnologyAssembler.Core.Hashing;
using System.Xml;
namespace HashCalculator.GUI
{
public static class SageHash
{
[SuppressMessage("MicrosoftCodeAnalysisCorrectness", "RS1024:Compare symbols correctly", Justification = "<Pending>")]
public static uint CalculateBinaryHash(byte[] content)
{
if (content == null)
{
throw new ArgumentNullException($"{nameof(content)} is null");
throw new ArgumentNullException(nameof(content));
}
return FastHash.GetHashCode(content);
}
@ -22,7 +22,7 @@ namespace HashCalculator.GUI
{
if (content == null)
{
throw new ArgumentNullException($"{nameof(content)} is null");
throw new ArgumentNullException(nameof(content));
}
return FastHash.GetHashCodeLauncher(0, content);
}
@ -31,26 +31,25 @@ namespace HashCalculator.GUI
{
if (content == null)
{
throw new ArgumentNullException($"{nameof(content)} is null");
throw new ArgumentNullException(nameof(content));
}
return CalculateBinaryHash(Encoding.ASCII.GetBytes(content));
}
[SuppressMessage("Globalization", "CA1308:将字符串规范化为大写", Justification = "<挂起>")]
public static uint CalculateLowercaseHash(string content)
{
if(content == null)
if (content == null)
{
throw new ArgumentNullException($"{nameof(content)} is null");
throw new ArgumentNullException(nameof(content));
}
return CalculateBinaryHash(content.ToLowerInvariant());
}
public static uint CalculateFileHash(string path)
{
if(path == null)
if (path == null)
{
throw new ArgumentNullException($"{nameof(path)} is null");
throw new ArgumentNullException(nameof(path));
}
return CalculateBinaryHash(File.ReadAllBytes(path));
}