mirror of
https://github.com/SabreTools/SabreTools.Hashing.git
synced 2026-02-13 13:46:11 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d91220a2e4 | ||
|
|
e60a1fbe3c | ||
|
|
978a3847de | ||
|
|
48da4cd88e |
18
.github/workflows/build_and_test.yml
vendored
18
.github/workflows/build_and_test.yml
vendored
@@ -9,17 +9,17 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: |
|
||||
6.0.x
|
||||
8.0.x
|
||||
9.0.x
|
||||
10.0.x
|
||||
|
||||
- name: Run tests
|
||||
run: dotnet test
|
||||
@@ -27,8 +27,16 @@ jobs:
|
||||
- name: Run publish script
|
||||
run: ./publish-nix.sh -d
|
||||
|
||||
- name: Update rolling tag
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git tag -f rolling
|
||||
git push origin :refs/tags/rolling || true
|
||||
git push origin rolling --force
|
||||
|
||||
- name: Upload to rolling
|
||||
uses: ncipollo/release-action@v1.14.0
|
||||
uses: ncipollo/release-action@v1.20.0
|
||||
with:
|
||||
allowUpdates: True
|
||||
artifacts: "*.nupkg,*.snupkg,*.zip"
|
||||
|
||||
6
.github/workflows/check_pr.yml
vendored
6
.github/workflows/check_pr.yml
vendored
@@ -6,15 +6,15 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: |
|
||||
6.0.x
|
||||
8.0.x
|
||||
9.0.x
|
||||
10.0.x
|
||||
|
||||
- name: Build
|
||||
run: dotnet build
|
||||
|
||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -10,7 +10,7 @@
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/Hasher/bin/Debug/net9.0/Hasher.dll",
|
||||
"program": "${workspaceFolder}/Hasher/bin/Debug/net10.0/Hasher.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<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;net10.0</TargetFrameworks>
|
||||
<OutputType>Exe</OutputType>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||
@@ -10,7 +10,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>1.5.1</Version>
|
||||
<Version>1.6.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Support All Frameworks -->
|
||||
@@ -24,14 +24,14 @@
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SabreTools.Hashing\SabreTools.Hashing.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.CommandLine" Version="[1.3.2]" />
|
||||
<PackageReference Include="SabreTools.CommandLine" Version="[1.4.0]" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -58,4 +58,4 @@ namespace SabreTools.Hashing.Test
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace SabreTools.Hashing.Test
|
||||
{
|
||||
get
|
||||
{
|
||||
var values = Enum.GetValues(typeof(HashType));
|
||||
var values = Enum.GetValues<HashType>();
|
||||
var set = new List<object[]>();
|
||||
foreach (var value in values)
|
||||
{
|
||||
@@ -126,4 +126,4 @@ namespace SabreTools.Hashing.Test
|
||||
TestHelper.ValidateHashes(hashDict);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
@@ -24,10 +24,9 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3">
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace SabreTools.Hashing.Test
|
||||
{
|
||||
get
|
||||
{
|
||||
var values = Enum.GetValues(typeof(HashType));
|
||||
var values = Enum.GetValues<HashType>();
|
||||
var set = new List<object[]>();
|
||||
foreach (var value in values)
|
||||
{
|
||||
@@ -46,4 +46,4 @@ namespace SabreTools.Hashing.Test
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using static SabreTools.Hashing.Checksum.Constants;
|
||||
|
||||
namespace SabreTools.Hashing.Checksum
|
||||
{
|
||||
/// <see href="https://github.com/madler/zlib/blob/v1.2.11/adler32.c"/>
|
||||
/// <see href="https://github.com/madler/zlib/blob/v1.2.11/adler32.c"/>
|
||||
public class Adler32 : ChecksumBase<uint>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace SabreTools.Hashing.Checksum
|
||||
{
|
||||
/// <see href="https://en.wikipedia.org/wiki/Fletcher%27s_checksum#Optimizations"/>
|
||||
/// <see href="https://en.wikipedia.org/wiki/Fletcher%27s_checksum#Optimizations"/>
|
||||
public class Fletcher16 : ChecksumBase<ushort>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,7 +2,7 @@ using static SabreTools.Hashing.Checksum.Constants;
|
||||
|
||||
namespace SabreTools.Hashing.Checksum
|
||||
{
|
||||
/// <see href="https://en.wikipedia.org/wiki/Fletcher%27s_checksum#Optimizations"/>
|
||||
/// <see href="https://en.wikipedia.org/wiki/Fletcher%27s_checksum#Optimizations"/>
|
||||
/// <remarks>Uses an Adler-32-like implementation instead of the above</remarks>
|
||||
public class Fletcher32 : ChecksumBase<uint>
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace SabreTools.Hashing.Checksum
|
||||
{
|
||||
/// <see href="https://github.com/ocornut/meka/blob/master/meka/srcs/checksum.cpp"/>
|
||||
/// <see href="https://github.com/ocornut/meka/blob/master/meka/srcs/checksum.cpp"/>
|
||||
public class MekaCrc : ChecksumBase<ulong>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -43,4 +43,4 @@ namespace SabreTools.Hashing.Checksum
|
||||
_hash = BitConverter.ToUInt64(temp, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
protected long _totalBytes;
|
||||
|
||||
/// <summary>
|
||||
/// Internal byte buffer to accumulate before <see cref="_block"/>
|
||||
/// Internal byte buffer to accumulate before <see cref="_block"/>
|
||||
/// </summary>
|
||||
protected readonly byte[] _buffer = new byte[64];
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// The official specification for RIPEMD-128 includes tables
|
||||
/// and instructions that represent a loop. Most standard implementations
|
||||
/// use the unrolled version of that loop to make it more efficient.
|
||||
///
|
||||
///
|
||||
/// The below code started with the looped version but has been converted
|
||||
/// to the more standard implementation instead.
|
||||
/// </remarks>
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// The official specification for RIPEMD-160 includes tables
|
||||
/// and instructions that represent a loop. Most standard implementations
|
||||
/// use the unrolled version of that loop to make it more efficient.
|
||||
///
|
||||
///
|
||||
/// The below code started with the looped version but has been converted
|
||||
/// to the more standard implementation instead.
|
||||
/// </remarks>
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// The official specification for RIPEMD-128 includes tables
|
||||
/// and instructions that represent a loop. Most standard implementations
|
||||
/// use the unrolled version of that loop to make it more efficient.
|
||||
///
|
||||
///
|
||||
/// The below code started with the looped version but has been converted
|
||||
/// to the more standard implementation instead.
|
||||
/// </remarks>
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace SabreTools.Hashing.CryptographicHash
|
||||
/// The official specification for RIPEMD-160 includes tables
|
||||
/// and instructions that represent a loop. Most standard implementations
|
||||
/// use the unrolled version of that loop to make it more efficient.
|
||||
///
|
||||
///
|
||||
/// The below code started with the looped version but has been converted
|
||||
/// to the more standard implementation instead.
|
||||
/// </remarks>
|
||||
|
||||
@@ -442,4 +442,4 @@ namespace SabreTools.Hashing
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace SabreTools.Hashing
|
||||
/// <summary>
|
||||
/// CRC 8-bit checksum
|
||||
/// </summary>
|
||||
/// <remarks>Identical to <see cref="CRC8_SMBUS"/>
|
||||
/// <remarks>Identical to <see cref="CRC8_SMBUS"/>
|
||||
CRC8,
|
||||
|
||||
/// <summary>
|
||||
@@ -337,7 +337,7 @@ namespace SabreTools.Hashing
|
||||
/// <summary>
|
||||
/// CRC 16-bit checksum
|
||||
/// </summary>
|
||||
/// <remarks>Identical to <see cref="CRC16_ARC"/>
|
||||
/// <remarks>Identical to <see cref="CRC16_ARC"/>
|
||||
CRC16,
|
||||
|
||||
/// <summary>
|
||||
@@ -582,7 +582,7 @@ namespace SabreTools.Hashing
|
||||
/// <summary>
|
||||
/// CRC 32-bit checksum
|
||||
/// </summary>
|
||||
/// <remarks>Identical to <see cref="CRC32_ISOHDLC"/>
|
||||
/// <remarks>Identical to <see cref="CRC32_ISOHDLC"/>
|
||||
CRC32,
|
||||
|
||||
/// <summary>
|
||||
@@ -661,7 +661,7 @@ namespace SabreTools.Hashing
|
||||
/// <summary>
|
||||
/// CRC 64-bit checksum
|
||||
/// </summary>
|
||||
/// <remarks>Identical to <see cref="CRC64_ECMA182"/>
|
||||
/// <remarks>Identical to <see cref="CRC64_ECMA182"/>
|
||||
CRC64,
|
||||
|
||||
/// <summary>
|
||||
@@ -840,7 +840,7 @@ namespace SabreTools.Hashing
|
||||
/// <summary>
|
||||
/// SHA3-512 hash
|
||||
/// </summary>
|
||||
SHA3_512,
|
||||
SHA3_512,
|
||||
|
||||
/// <summary>
|
||||
/// SHAKE128 SHA-3 family hash
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace SabreTools.Hashing
|
||||
/// </summary>
|
||||
/// <param name="cr">Crc to get the value from</param>
|
||||
/// <returns>String representing the CRC, null on error</returns>
|
||||
private string? GetCRCVariableLengthString(Crc cr)
|
||||
private static string? GetCRCVariableLengthString(Crc cr)
|
||||
{
|
||||
// Ignore null values
|
||||
if (cr.Hash == null)
|
||||
@@ -364,7 +364,7 @@ namespace SabreTools.Hashing
|
||||
/// </summary>
|
||||
/// <param name="ss">SpamSum to get the value from</param>
|
||||
/// <returns>String representing the SpamSum, null on error</returns>
|
||||
private string? GetSpamSumBase64String(SpamSum.SpamSum ss)
|
||||
private static string? GetSpamSumBase64String(SpamSum.SpamSum ss)
|
||||
{
|
||||
// Ignore null values
|
||||
if (ss.Hash == null)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
/// <summary>
|
||||
/// Structure for xxHash-32 streaming API.
|
||||
/// </summary>
|
||||
/// <see href="https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h"/>
|
||||
/// <see href="https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h"/>
|
||||
internal class XxHash32State
|
||||
{
|
||||
/// <summary>
|
||||
@@ -137,7 +137,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
|
||||
/// <summary>
|
||||
/// Normal stripe processing routine.
|
||||
///
|
||||
///
|
||||
/// This shuffles the bits so that any bit from <paramref name="input"/> impacts
|
||||
/// several bits in <paramref name="acc"/>.
|
||||
/// </summary>
|
||||
@@ -154,7 +154,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
|
||||
/// <summary>
|
||||
/// Mixes all bits to finalize the hash.
|
||||
///
|
||||
///
|
||||
/// The final mix ensures that all input bits have a chance to impact any bit in
|
||||
/// the output digest, resulting in an unbiased distribution.
|
||||
/// </summary>
|
||||
@@ -170,7 +170,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
|
||||
/// <summary>
|
||||
/// Processes the last 0-15 bytes of @p ptr.
|
||||
///
|
||||
///
|
||||
/// There may be up to 15 bytes remaining to consume from the input.
|
||||
/// This final stage will digest them to ensure that all input bytes are present
|
||||
/// in the final mix.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
/// <summary>
|
||||
/// Structure for xxHash-64 streaming API.
|
||||
/// </summary>
|
||||
/// <see href="https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h"/>
|
||||
/// <see href="https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h"/>
|
||||
internal class XxHash64State
|
||||
{
|
||||
/// <summary>
|
||||
@@ -134,7 +134,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
|
||||
/// <summary>
|
||||
/// Normal stripe processing routine.
|
||||
///
|
||||
///
|
||||
/// This shuffles the bits so that any bit from @p input impacts
|
||||
/// several bits in @p acc.
|
||||
/// </summary>
|
||||
@@ -159,7 +159,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
|
||||
/// <summary>
|
||||
/// Processes the last 0-31 bytes of @p ptr.
|
||||
///
|
||||
///
|
||||
/// There may be up to 31 bytes remaining to consume from the input.
|
||||
/// This final stage will digest them to ensure that all input bytes are present
|
||||
/// in the final mix.
|
||||
@@ -202,7 +202,7 @@ namespace SabreTools.Hashing.NonCryptographicHash
|
||||
|
||||
/// <summary>
|
||||
/// Mixes all bits to finalize the hash.
|
||||
///
|
||||
///
|
||||
/// The final mix ensures that all input bits have a chance to impact any bit in
|
||||
/// the output digest, resulting in an unbiased distribution.
|
||||
/// </summary>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Assembly Properties -->
|
||||
<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>
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.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.5.1</Version>
|
||||
<Version>1.6.0</Version>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Matt Nadareski</Authors>
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
<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`))" />
|
||||
<PackageReference Include="Blake3" Version="2.0.0" Condition="$(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`)) OR $(TargetFramework.StartsWith(`net10`))" />
|
||||
<PackageReference Include="System.IO.Hashing" Version="10.0.0" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net45`))" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -6,7 +6,7 @@ namespace SabreTools.Hashing.SpamSum
|
||||
/// A blockhash contains a signature state for a specific (implicit) blocksize.
|
||||
/// The blocksize is given by <see cref="SSDEEP_BS(uint)"/>
|
||||
/// </summary>
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
internal class BlockhashContext
|
||||
{
|
||||
/// <summary>
|
||||
@@ -20,7 +20,7 @@ namespace SabreTools.Hashing.SpamSum
|
||||
public byte[] Digest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Digest value at <see cref="HalfH"/>
|
||||
/// Digest value at <see cref="HalfH"/>
|
||||
/// </summary>
|
||||
public byte HalfDigest { get; set; }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ internal static class Comparisons
|
||||
/// <summary>
|
||||
/// Regex to reduce any sequences longer than 3
|
||||
/// </summary>
|
||||
private static Regex _reduceRegex = new("(.)(?<=\\1\\1\\1\\1)", RegexOptions.Compiled);
|
||||
private static readonly Regex _reduceRegex = new("(.)(?<=\\1\\1\\1\\1)", RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// Compares how similar two SpamSums are to each other
|
||||
@@ -17,7 +17,7 @@ internal static class Comparisons
|
||||
/// <param name="second">Second hash to compare</param>
|
||||
/// <returns>-1 on validity failure, 0 if they're not comparable, score from 0 (least similar) to 100 (most similar) otherwise.</returns>
|
||||
/// <remarks>Implements ssdeep's fuzzy_compare</remarks>
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/df3b860f8918261b3faeec9c7d2c8a241089e6e6/fuzzy.c#L860"/>
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/df3b860f8918261b3faeec9c7d2c8a241089e6e6/fuzzy.c#L860"/>
|
||||
public static int FuzzyCompare(string? first, string? second)
|
||||
{
|
||||
// If either input is invalid
|
||||
@@ -163,9 +163,13 @@ internal static class Comparisons
|
||||
secondTraverse[secondIndex + 1] = Math.Min(Math.Min(costA, costD), costR);
|
||||
}
|
||||
|
||||
#if NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
(secondTraverse, firstTraverse) = (firstTraverse, secondTraverse);
|
||||
#else
|
||||
var tempArray = firstTraverse;
|
||||
firstTraverse = secondTraverse;
|
||||
secondTraverse = tempArray;
|
||||
#endif
|
||||
}
|
||||
|
||||
long score = firstTraverse[second.Length];
|
||||
|
||||
@@ -2,8 +2,8 @@ using System.Text;
|
||||
|
||||
namespace SabreTools.Hashing.SpamSum
|
||||
{
|
||||
/// <see href="github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
/// <see href="github.com/ssdeep-project/ssdeep/blob/master/fuzzy.h"/>
|
||||
/// <see href="github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
/// <see href="github.com/ssdeep-project/ssdeep/blob/master/fuzzy.h"/>
|
||||
internal static class Constants
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,7 @@ using static SabreTools.Hashing.SpamSum.Constants;
|
||||
|
||||
namespace SabreTools.Hashing.SpamSum
|
||||
{
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
internal class FuzzyState
|
||||
{
|
||||
public ulong TotalSize { get; set; }
|
||||
|
||||
@@ -2,7 +2,7 @@ using static SabreTools.Hashing.SpamSum.Constants;
|
||||
|
||||
namespace SabreTools.Hashing.SpamSum
|
||||
{
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
internal class RollState
|
||||
{
|
||||
public byte[] Window { get; set; }
|
||||
@@ -23,10 +23,10 @@ namespace SabreTools.Hashing.SpamSum
|
||||
/// <summary>
|
||||
/// A rolling hash, based on the Adler checksum. By using a rolling hash
|
||||
/// we can perform auto resynchronisation after inserts/deletes.
|
||||
///
|
||||
///
|
||||
/// Internally, H1 is the sum of the bytes in the window and H2
|
||||
/// is the sum of the bytes times the index.
|
||||
///
|
||||
///
|
||||
/// H3 is a shift/xor based rolling hash, and is mostly needed to ensure that
|
||||
/// we can cope with large blocksize values.
|
||||
/// </summary>
|
||||
|
||||
@@ -4,7 +4,7 @@ using static SabreTools.Hashing.SpamSum.Constants;
|
||||
|
||||
namespace SabreTools.Hashing.SpamSum
|
||||
{
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
/// <see href="https://github.com/ssdeep-project/ssdeep/blob/master/fuzzy.c"/>
|
||||
public class SpamSum : System.Security.Cryptography.HashAlgorithm
|
||||
{
|
||||
private FuzzyState _state;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace SabreTools.Hashing.XxHash
|
||||
|
||||
/// <summary>
|
||||
/// Mixes all bits to finalize the hash.
|
||||
///
|
||||
///
|
||||
/// The final mix ensures that all input bits have a chance to impact any bit in
|
||||
/// the output digest, resulting in an unbiased distribution.
|
||||
/// </summary>
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SabreTools.Hashing.XxHash
|
||||
/// <summary>
|
||||
/// Structure for XXH3 streaming API.
|
||||
/// </summary>
|
||||
/// <see href="https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h"/>
|
||||
/// <see href="https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h"/>
|
||||
internal class XXH3_128State
|
||||
{
|
||||
/// <summary>
|
||||
@@ -27,7 +27,7 @@ namespace SabreTools.Hashing.XxHash
|
||||
private readonly byte[] _buffer = new byte[Constants.XXH3_INTERNALBUFFER_SIZE];
|
||||
|
||||
/// <summary>
|
||||
/// The amount of memory in <see cref="_buffer"/>, <see cref="XXH32State._memsize"/>
|
||||
/// The amount of memory in <see cref="_buffer"/>, <see cref="XXH32State._memsize"/>
|
||||
/// </summary>
|
||||
private uint _bufferedSize;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SabreTools.Hashing.XxHash
|
||||
/// <summary>
|
||||
/// Structure for XXH3 streaming API.
|
||||
/// </summary>
|
||||
/// <see href="https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h"/>
|
||||
/// <see href="https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h"/>
|
||||
internal class XXH3_64State
|
||||
{
|
||||
/// <summary>
|
||||
@@ -27,7 +27,7 @@ namespace SabreTools.Hashing.XxHash
|
||||
private readonly byte[] _buffer = new byte[Constants.XXH3_INTERNALBUFFER_SIZE];
|
||||
|
||||
/// <summary>
|
||||
/// The amount of memory in <see cref="_buffer"/>, <see cref="XXH32State._memsize"/>
|
||||
/// The amount of memory in <see cref="_buffer"/>, <see cref="XXH32State._memsize"/>
|
||||
/// </summary>
|
||||
private uint _bufferedSize;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This batch file assumes the following:
|
||||
# - .NET 9.0 (or newer) SDK is installed and in PATH
|
||||
# - .NET 10.0 (or newer) SDK is installed and in PATH
|
||||
# - zip is installed and in PATH
|
||||
# - Git is installed and in PATH
|
||||
#
|
||||
@@ -49,18 +49,18 @@ echo " No archive (-a) $NO_ARCHIVE"
|
||||
echo " "
|
||||
|
||||
# Create the build matrix arrays
|
||||
FRAMEWORKS=("net9.0")
|
||||
FRAMEWORKS=("net10.0")
|
||||
RUNTIMES=("win-x86" "win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64")
|
||||
|
||||
# Use expanded lists, if requested
|
||||
if [ $USE_ALL = true ]; then
|
||||
FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
|
||||
FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0" "net10.0")
|
||||
fi
|
||||
|
||||
# Create the filter arrays
|
||||
SINGLE_FILE_CAPABLE=("net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
|
||||
VALID_APPLE_FRAMEWORKS=("net6.0" "net7.0" "net8.0" "net9.0")
|
||||
VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
|
||||
SINGLE_FILE_CAPABLE=("net5.0" "net6.0" "net7.0" "net8.0" "net9.0" "net10.0")
|
||||
VALID_APPLE_FRAMEWORKS=("net6.0" "net7.0" "net8.0" "net9.0" "net10.0")
|
||||
VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0" "net10.0")
|
||||
VALID_CROSS_PLATFORM_RUNTIMES=("win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64")
|
||||
|
||||
# Only build if requested
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# This batch file assumes the following:
|
||||
# - .NET 9.0 (or newer) SDK is installed and in PATH
|
||||
# - .NET 10.0 (or newer) SDK is installed and in PATH
|
||||
#
|
||||
# If any of these are not satisfied, the operation may fail
|
||||
# in an unpredictable way and result in an incomplete output.
|
||||
@@ -38,18 +38,18 @@ Write-Host " No archive (-NoArchive) $NO_ARCHIVE"
|
||||
Write-Host " "
|
||||
|
||||
# Create the build matrix arrays
|
||||
$FRAMEWORKS = @('net9.0')
|
||||
$FRAMEWORKS = @('net10.0')
|
||||
$RUNTIMES = @('win-x86', 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')
|
||||
|
||||
# Use expanded lists, if requested
|
||||
if ($USE_ALL.IsPresent) {
|
||||
$FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
|
||||
$FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0', 'net10.0')
|
||||
}
|
||||
|
||||
# Create the filter arrays
|
||||
$SINGLE_FILE_CAPABLE = @('net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
|
||||
$VALID_APPLE_FRAMEWORKS = @('net6.0', 'net7.0', 'net8.0', 'net9.0')
|
||||
$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
|
||||
$SINGLE_FILE_CAPABLE = @('net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0', 'net10.0')
|
||||
$VALID_APPLE_FRAMEWORKS = @('net6.0', 'net7.0', 'net8.0', 'net9.0', 'net10.0')
|
||||
$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0', 'net10.0')
|
||||
$VALID_CROSS_PLATFORM_RUNTIMES = @('win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')
|
||||
|
||||
# Only build if requested
|
||||
|
||||
Reference in New Issue
Block a user