Add HashSize property for all implementations

This commit is contained in:
Matt Nadareski
2025-01-02 15:37:20 -05:00
parent 4e0da77cb4
commit f971fcf5c8
31 changed files with 93 additions and 0 deletions

View File

@@ -6,6 +6,9 @@ namespace SabreTools.Hashing.Checksum
/// <see href="https://github.com/madler/zlib/blob/v1.2.11/adler32.c"/>
public class Adler32 : ChecksumBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 32;
public Adler32()
{
Initialize();

View File

@@ -5,6 +5,9 @@ namespace SabreTools.Hashing.Checksum
{
public class Crc : ChecksumBase<ulong>
{
/// <inheritdoc/>
public override int HashSize => Def.Width;
/// <summary>
/// Definition used to create the runner
/// </summary>

View File

@@ -3,6 +3,9 @@ namespace SabreTools.Hashing.Checksum
/// <see href="https://en.wikipedia.org/wiki/Fletcher%27s_checksum#Optimizations"/>
public class Fletcher16 : ChecksumBase<ushort>
{
/// <inheritdoc/>
public override int HashSize => 16;
public Fletcher16()
{
Initialize();

View File

@@ -6,6 +6,9 @@ namespace SabreTools.Hashing.Checksum
/// <remarks>Uses an Adler-32-like implementation instead of the above</remarks>
public class Fletcher32 : ChecksumBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 32;
public Fletcher32()
{
Initialize();

View File

@@ -6,6 +6,9 @@ namespace SabreTools.Hashing.Checksum
/// <remarks>Uses an Adler-32-like implementation instead of the above</remarks>
public class Fletcher64 : ChecksumBase<ulong>
{
/// <inheritdoc/>
public override int HashSize => 64;
public Fletcher64()
{
Initialize();

View File

@@ -6,6 +6,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// <see href="https://datatracker.ietf.org/doc/html/rfc1115"/>
public class MD2 : MessageDigestBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 128;
/// <summary>
/// Buffer for forming digest in
/// </summary>

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// <see href="https://datatracker.ietf.org/doc/html/rfc1320"/>
public class MD4 : MessageDigestBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 128;
/// <summary>
/// Set of 4 32-bit numbers representing the hash state
/// </summary>

View File

@@ -8,6 +8,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// <see href="https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf"/>
public class RipeMD128 : MessageDigestBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 128;
/// <summary>
/// Set of 4 32-bit numbers representing the hash state
/// </summary>

View File

@@ -8,6 +8,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// <see href="https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf"/>
public class RipeMD160 : MessageDigestBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 160;
/// <summary>
/// Set of 5 32-bit numbers representing the hash state
/// </summary>

View File

@@ -8,6 +8,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// <see href="https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf"/>
public class RipeMD256 : MessageDigestBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 256;
/// <summary>
/// Set of 4 32-bit numbers representing the hash state
/// </summary>

View File

@@ -8,6 +8,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// <see href="https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf"/>
public class RipeMD320 : MessageDigestBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 320;
/// <summary>
/// Set of 10 32-bit numbers representing the hash state
/// </summary>

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger128_3 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 128;
public Tiger128_3() : base()
{
_passes = 3;

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger128_4 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 128;
public Tiger128_4() : base()
{
_passes = 4;

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger160_3 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 160;
public Tiger160_3() : base()
{
_passes = 3;

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger160_4 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 160;
public Tiger160_4() : base()
{
_passes = 4;

View File

@@ -5,6 +5,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger192_3 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 192;
public Tiger192_3() : base()
{
_passes = 3;

View File

@@ -5,6 +5,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger192_4 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 192;
public Tiger192_4() : base()
{
_passes = 4;

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger2_128_3 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 128;
public Tiger2_128_3() : base()
{
_passes = 3;

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger2_128_4 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 128;
public Tiger2_128_4() : base()
{
_passes = 4;

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger2_160_3 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 160;
public Tiger2_160_3() : base()
{
_passes = 3;

View File

@@ -7,6 +7,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger2_160_4 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 160;
public Tiger2_160_4() : base()
{
_passes = 4;

View File

@@ -5,6 +5,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger2_192_3 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 192;
public Tiger2_192_3() : base()
{
_passes = 3;

View File

@@ -5,6 +5,9 @@ namespace SabreTools.Hashing.CryptographicHash
/// </summary>
public class Tiger2_192_4 : TigerHashBase
{
/// <inheritdoc/>
public override int HashSize => 192;
public Tiger2_192_4() : base()
{
_passes = 4;

View File

@@ -4,6 +4,9 @@ namespace SabreTools.Hashing.NonCryptographicHash
{
public class FNV0_32 : FnvBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 32;
public FNV0_32()
{
_basis = 0;

View File

@@ -4,6 +4,9 @@ namespace SabreTools.Hashing.NonCryptographicHash
{
public class FNV0_64 : FnvBase<ulong>
{
/// <inheritdoc/>
public override int HashSize => 64;
public FNV0_64()
{
_basis = 0;

View File

@@ -4,6 +4,9 @@ namespace SabreTools.Hashing.NonCryptographicHash
{
public class FNV1_32 : FnvBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 32;
public FNV1_32()
{
_basis = FNV32Basis;

View File

@@ -4,6 +4,9 @@ namespace SabreTools.Hashing.NonCryptographicHash
{
public class FNV1_64 : FnvBase<ulong>
{
/// <inheritdoc/>
public override int HashSize => 64;
public FNV1_64()
{
_basis = FNV64Basis;

View File

@@ -4,6 +4,9 @@ namespace SabreTools.Hashing.NonCryptographicHash
{
public class FNV1a_32 : FnvBase<uint>
{
/// <inheritdoc/>
public override int HashSize => 32;
public FNV1a_32()
{
_basis = FNV32Basis;

View File

@@ -4,6 +4,9 @@ namespace SabreTools.Hashing.NonCryptographicHash
{
public class FNV1a_64 : FnvBase<ulong>
{
/// <inheritdoc/>
public override int HashSize => 64;
public FNV1a_64()
{
_basis = FNV64Basis;

View File

@@ -4,6 +4,9 @@ namespace SabreTools.Hashing.NonCryptographicHash
{
public class XxHash32 : System.Security.Cryptography.HashAlgorithm
{
/// <inheritdoc/>
public override int HashSize => 32;
/// <summary>
/// The 32-bit seed to alter the hash result predictably.
/// </summary>

View File

@@ -4,6 +4,9 @@ namespace SabreTools.Hashing.NonCryptographicHash
{
public class XxHash64 : System.Security.Cryptography.HashAlgorithm
{
/// <inheritdoc/>
public override int HashSize => 64;
/// <summary>
/// The 64-bit seed to alter the hash result predictably.
/// </summary>