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