HashCalculator.GUI/SageHash.cs
2022-01-25 13:37:44 +01:00

58 lines
1.7 KiB
C#

using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
using TechnologyAssembler.Core.Hashing;
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));
}
return FastHash.GetHashCode(content);
}
public static uint CalculateLauncherBinaryHash(byte[] content)
{
if (content == null)
{
throw new ArgumentNullException(nameof(content));
}
return FastHash.GetHashCodeLauncher(0, content);
}
public static uint CalculateBinaryHash(string content)
{
if (content == null)
{
throw new ArgumentNullException(nameof(content));
}
return CalculateBinaryHash(Encoding.ASCII.GetBytes(content));
}
public static uint CalculateLowercaseHash(string content)
{
if (content == null)
{
throw new ArgumentNullException(nameof(content));
}
return CalculateBinaryHash(content.ToLowerInvariant());
}
public static uint CalculateFileHash(string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
return CalculateBinaryHash(File.ReadAllBytes(path));
}
}
}