mirror of
https://github.com/SabreTools/SabreTools.Hashing.git
synced 2026-02-09 21:35:02 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd612f939a | ||
|
|
8e3a0f77e9 | ||
|
|
40cfa78be4 | ||
|
|
4d92c7cd23 | ||
|
|
acf1e3ec71 | ||
|
|
10027f78e3 |
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net462;net472;net48;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
@@ -20,14 +20,14 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -136,9 +136,9 @@ namespace SabreTools.Hashing.Checksum
|
||||
/// <inheritdoc/>
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
byte[] hashArr = BitConverter.GetBytes(_hash);
|
||||
byte[] hashArr = BitConverter.GetBytes(_hash);
|
||||
Array.Reverse(hashArr);
|
||||
return hashArr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
return hashArr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,4 +56,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
return BitOperations.ClampValueToBytes(localHash, Def.Width);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,4 +62,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
/// </summary>
|
||||
public ulong XorOut { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,4 +330,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
hash = local;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,4 +41,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
_hash = (ushort)((c1 << 8) | c0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,4 +125,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
_hash = (c1 << 16) | c0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,4 +125,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
_hash = (c1 << 32) | c0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1687,4 +1687,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ namespace SabreTools.Hashing
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,4 +694,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
|
||||
// Pad the block
|
||||
byte[] padding = new byte[padLength];
|
||||
#if NETFRAMEWORK
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0
|
||||
for (int i = 0; i < padLength; i++)
|
||||
{
|
||||
padding[i] = padLength;
|
||||
@@ -166,4 +166,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,4 +211,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// </summary>
|
||||
private static uint H(uint x, uint y, uint z) => x ^ y ^ z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
Array.Clear(_block, 0, _block.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,4 +444,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// </summary>
|
||||
private static uint G48_63(uint x, uint y, uint z) => (x & z) | (y & ~z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,4 +680,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// </summary>
|
||||
private static uint G64_79(uint x, uint y, uint z) => x ^ (y | ~z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,4 +464,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// </summary>
|
||||
private static uint G48_63(uint x, uint y, uint z) => (x & z) | (y & ~z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,4 +705,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// </summary>
|
||||
private static uint G64_79(uint x, uint y, uint z) => x ^ (y | ~z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
return trimmedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
return trimmedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
return trimmedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
return trimmedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
_padStart = 0x01;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
_padStart = 0x01;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
return trimmedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
return trimmedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
return trimmedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
return trimmedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
_padStart = 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
_padStart = 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,4 +234,4 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
_block[7] -= _block[6] ^ 0x0123456789ABCDEF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,4 +178,4 @@ namespace SabreTools.Hashing
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
using System.Threading.Tasks;
|
||||
#endif
|
||||
|
||||
@@ -753,4 +753,4 @@ namespace SabreTools.Hashing
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,4 +947,4 @@ namespace SabreTools.Hashing
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,4 +373,4 @@ namespace SabreTools.Hashing
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
return hashArr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
return hashArr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
private static uint Round(uint acc, uint input)
|
||||
{
|
||||
acc += input * XXH_PRIME32_2;
|
||||
acc = RotateLeft32(acc, 13);
|
||||
acc = RotateLeft32(acc, 13);
|
||||
acc *= XXH_PRIME32_1;
|
||||
return acc;
|
||||
}
|
||||
@@ -201,4 +201,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
return Avalanche(hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
return hashArr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
private static ulong Round(ulong acc, ulong input)
|
||||
{
|
||||
acc += unchecked(input * XXH_PRIME64_2);
|
||||
acc = RotateLeft64(acc, 31);
|
||||
acc = RotateLeft64(acc, 31);
|
||||
acc *= XXH_PRIME64_1;
|
||||
return acc;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
|
||||
return Avalanche(hash);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Mixes all bits to finalize the hash.
|
||||
///
|
||||
@@ -216,4 +216,4 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;netstandard2.0;netstandard2.1</TargetFrameworks>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
@@ -11,7 +11,7 @@
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>1.4.2</Version>
|
||||
<Version>1.5.0</Version>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Matt Nadareski</Authors>
|
||||
@@ -28,12 +28,10 @@
|
||||
<None Include="../README.md" Pack="true" PackagePath="" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Support for old .NET versions -->
|
||||
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net45`))">
|
||||
<PackageReference Include="System.IO.Hashing" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))">
|
||||
<PackageReference Include="Blake3" Version="1.1.0" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blake3" Version="1.1.0" Condition="$(TargetFramework.StartsWith(`net7`))" />
|
||||
<PackageReference Include="Blake3" Version="2.0.0" Condition="$(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))" />
|
||||
<PackageReference Include="System.IO.Hashing" Version="9.0.7" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net45`))" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -42,4 +42,4 @@ namespace SabreTools.Hashing.SpamSum
|
||||
Digest = new byte[SPAMSUM_LENGTH];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,4 +443,4 @@ namespace SabreTools.Hashing.SpamSum
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace SabreTools.Hashing.SpamSum
|
||||
LastH = BH[obh].H;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void TryReduceBlockhash()
|
||||
{
|
||||
if (BHStart >= BHEnd)
|
||||
@@ -88,4 +88,4 @@ namespace SabreTools.Hashing.SpamSum
|
||||
RollMask = RollMask * 2 + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ namespace SabreTools.Hashing.SpamSum
|
||||
H3 <<= 5;
|
||||
H3 ^= c;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Return the current rolling sum
|
||||
/// </summary>
|
||||
public uint RollSum() => H1 + H2 + H3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,4 +353,4 @@ namespace SabreTools.Hashing.SpamSum
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,4 +67,4 @@ namespace SabreTools.Hashing.XxHash
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,4 +71,4 @@ namespace SabreTools.Hashing.XxHash
|
||||
/// </summary>
|
||||
XXH_SVE = 6,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,4 +249,4 @@ namespace SabreTools.Hashing.XxHash
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace SabreTools.Hashing.XxHash
|
||||
internal class XXH3_128Hash
|
||||
{
|
||||
public ulong Low { get; set; }
|
||||
|
||||
|
||||
public ulong High { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace SabreTools.Hashing.XxHash
|
||||
{
|
||||
// Handle unused private fields
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS0414
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS0414
|
||||
#pragma warning disable CS0649
|
||||
|
||||
/// <summary>
|
||||
/// Structure for XXH3 streaming API.
|
||||
@@ -106,7 +106,7 @@ namespace SabreTools.Hashing.XxHash
|
||||
{
|
||||
// TODO: XXH3_128bits_reset_withSecret
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Hash a block of data and append it to the existing hash
|
||||
/// </summary>
|
||||
@@ -128,4 +128,4 @@ namespace SabreTools.Hashing.XxHash
|
||||
return ulong.MaxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace SabreTools.Hashing.XxHash
|
||||
{
|
||||
// Handle unused private fields
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS0414
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS0414
|
||||
#pragma warning disable CS0649
|
||||
|
||||
/// <summary>
|
||||
/// Structure for XXH3 streaming API.
|
||||
@@ -111,7 +111,7 @@ namespace SabreTools.Hashing.XxHash
|
||||
{
|
||||
// TODO: XXH3_64bits_reset_withSecret
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Hash a block of data and append it to the existing hash
|
||||
/// </summary>
|
||||
@@ -133,4 +133,4 @@ namespace SabreTools.Hashing.XxHash
|
||||
return ulong.MaxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,4 +620,4 @@ namespace SabreTools.Hashing
|
||||
return _strings[hashType];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user