修
This commit is contained in:
parent
6ce486945b
commit
bedc003966
@ -12,7 +12,7 @@ namespace HashCalculator.GUI
|
|||||||
public string Type { get; }
|
public string Type { get; }
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public string NameString { get; }
|
public string NameString { get; }
|
||||||
public IEnumerable<string> DisplayLabels { get; }
|
public IReadOnlyList<string> DisplayLabels { get; }
|
||||||
public uint InstanceId => SageHash.CalculateLowercaseHash(Name);
|
public uint InstanceId => SageHash.CalculateLowercaseHash(Name);
|
||||||
|
|
||||||
public string InstanceIdString => $"{InstanceId:x8} ({InstanceId,10})";
|
public string InstanceIdString => $"{InstanceId:x8} ({InstanceId,10})";
|
||||||
|
17
SageHash.cs
17
SageHash.cs
@ -3,17 +3,17 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using TechnologyAssembler.Core.Hashing;
|
using TechnologyAssembler.Core.Hashing;
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
namespace HashCalculator.GUI
|
namespace HashCalculator.GUI
|
||||||
{
|
{
|
||||||
public static class SageHash
|
public static class SageHash
|
||||||
{
|
{
|
||||||
|
[SuppressMessage("MicrosoftCodeAnalysisCorrectness", "RS1024:Compare symbols correctly", Justification = "<Pending>")]
|
||||||
public static uint CalculateBinaryHash(byte[] content)
|
public static uint CalculateBinaryHash(byte[] content)
|
||||||
{
|
{
|
||||||
if (content == null)
|
if (content == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException($"{nameof(content)} is null");
|
throw new ArgumentNullException(nameof(content));
|
||||||
}
|
}
|
||||||
return FastHash.GetHashCode(content);
|
return FastHash.GetHashCode(content);
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ namespace HashCalculator.GUI
|
|||||||
{
|
{
|
||||||
if (content == null)
|
if (content == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException($"{nameof(content)} is null");
|
throw new ArgumentNullException(nameof(content));
|
||||||
}
|
}
|
||||||
return FastHash.GetHashCodeLauncher(0, content);
|
return FastHash.GetHashCodeLauncher(0, content);
|
||||||
}
|
}
|
||||||
@ -31,26 +31,25 @@ namespace HashCalculator.GUI
|
|||||||
{
|
{
|
||||||
if (content == null)
|
if (content == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException($"{nameof(content)} is null");
|
throw new ArgumentNullException(nameof(content));
|
||||||
}
|
}
|
||||||
return CalculateBinaryHash(Encoding.ASCII.GetBytes(content));
|
return CalculateBinaryHash(Encoding.ASCII.GetBytes(content));
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("Globalization", "CA1308:将字符串规范化为大写", Justification = "<挂起>")]
|
|
||||||
public static uint CalculateLowercaseHash(string content)
|
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());
|
return CalculateBinaryHash(content.ToLowerInvariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static uint CalculateFileHash(string path)
|
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));
|
return CalculateBinaryHash(File.ReadAllBytes(path));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user