mirror of
https://github.com/SabreTools/SabreTools.Hashing.git
synced 2026-09-24 15:55:02 +00:00
Correctly label CRC64 implementations, extend to old .NET
This commit is contained in:
@@ -18,10 +18,8 @@ namespace SabreTools.Hashing.Test
|
||||
private const string _crc16_ccitt = "482d";
|
||||
private const string _crc16_ibm = "7573";
|
||||
private const string _crc32 = "ba02a660";
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
private const string _crc64 = "a0e0009c18b5338d";
|
||||
#endif
|
||||
private const string _crc64_ecma = "fb49044e8331f6e5";
|
||||
private const string _crc64_reversed = "fb49044e8331f6e5";
|
||||
private const string _fletcher16 = "46c1";
|
||||
private const string _fletcher32 = "073f2d94";
|
||||
private const string _md5 = "b722871eaa950016296184d026c5dec9";
|
||||
@@ -71,10 +69,8 @@ namespace SabreTools.Hashing.Test
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Naive]);
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Optimized]);
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Parallel]);
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
Assert.Equal(_crc64, hashDict[HashType.CRC64]);
|
||||
#endif
|
||||
Assert.Equal(_crc64_ecma, hashDict[HashType.CRC64_ECMA]);
|
||||
Assert.Equal(_crc64_reversed, hashDict[HashType.CRC64_Reversed]);
|
||||
Assert.Equal(_fletcher16, hashDict[HashType.Fletcher16]);
|
||||
Assert.Equal(_fletcher32, hashDict[HashType.Fletcher32]);
|
||||
Assert.Equal(_md5, hashDict[HashType.MD5]);
|
||||
@@ -112,10 +108,8 @@ namespace SabreTools.Hashing.Test
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Naive]);
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Optimized]);
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Parallel]);
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
Assert.Equal(_crc64, hashDict[HashType.CRC64]);
|
||||
#endif
|
||||
Assert.Equal(_crc64_ecma, hashDict[HashType.CRC64_ECMA]);
|
||||
Assert.Equal(_crc64_reversed, hashDict[HashType.CRC64_Reversed]);
|
||||
Assert.Equal(_fletcher16, hashDict[HashType.Fletcher16]);
|
||||
Assert.Equal(_fletcher32, hashDict[HashType.Fletcher32]);
|
||||
Assert.Equal(_md5, hashDict[HashType.MD5]);
|
||||
@@ -150,10 +144,8 @@ namespace SabreTools.Hashing.Test
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Naive]);
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Optimized]);
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Parallel]);
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
Assert.Equal(_crc64, hashDict[HashType.CRC64]);
|
||||
#endif
|
||||
Assert.Equal(_crc64_ecma, hashDict[HashType.CRC64_ECMA]);
|
||||
Assert.Equal(_crc64_reversed, hashDict[HashType.CRC64_Reversed]);
|
||||
Assert.Equal(_fletcher16, hashDict[HashType.Fletcher16]);
|
||||
Assert.Equal(_fletcher32, hashDict[HashType.Fletcher32]);
|
||||
Assert.Equal(_md5, hashDict[HashType.MD5]);
|
||||
@@ -188,10 +180,8 @@ namespace SabreTools.Hashing.Test
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Naive]);
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Optimized]);
|
||||
Assert.Equal(_crc32, hashDict[HashType.CRC32_Parallel]);
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
Assert.Equal(_crc64, hashDict[HashType.CRC64]);
|
||||
#endif
|
||||
Assert.Equal(_crc64_ecma, hashDict[HashType.CRC64_ECMA]);
|
||||
Assert.Equal(_crc64_reversed, hashDict[HashType.CRC64_Reversed]);
|
||||
Assert.Equal(_fletcher16, hashDict[HashType.Fletcher16]);
|
||||
Assert.Equal(_fletcher32, hashDict[HashType.Fletcher32]);
|
||||
Assert.Equal(_md5, hashDict[HashType.MD5]);
|
||||
|
||||
@@ -53,17 +53,15 @@ namespace SabreTools.Hashing
|
||||
/// </summary>
|
||||
CRC32_Parallel,
|
||||
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
/// <summary>
|
||||
/// CRC 64-bit checksum
|
||||
/// CRC 64-bit checksum (0x42F0E1EBA9EA3693 polynomial)
|
||||
/// </summary>
|
||||
CRC64,
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// CRC 64-bit checksum (ECMA implementation)
|
||||
/// CRC 64-bit checksum (0xC96C5795D7870F42 polynomial)
|
||||
/// </summary>
|
||||
CRC64_ECMA,
|
||||
CRC64_Reversed,
|
||||
|
||||
/// <summary>
|
||||
/// John G. Fletcher's 16-bit checksum
|
||||
|
||||
@@ -76,6 +76,11 @@ namespace SabreTools.Hashing
|
||||
/// <remarks>May be either a HashAlgorithm or NonCryptographicHashAlgorithm</remarks>
|
||||
private object? _hasher;
|
||||
|
||||
/// <summary>
|
||||
/// Non-reversed CRC-64 polynomial
|
||||
/// </summary>
|
||||
private const ulong CRC64_ECMA_POLY_NORMAL = 0x42F0E1EBA9EA3693;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@@ -114,8 +119,10 @@ namespace SabreTools.Hashing
|
||||
HashType.CRC32_Parallel => new ParallelCRC(),
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
HashType.CRC64 => new Crc64(),
|
||||
#else
|
||||
HashType.CRC64 => new Crc64Context(CRC64_ECMA_POLY_NORMAL, 0xFFFFFFFFFFFFFFFF),
|
||||
#endif
|
||||
HashType.CRC64_ECMA => new Crc64Context(),
|
||||
HashType.CRC64_Reversed => new Crc64Context(),
|
||||
HashType.Fletcher16 => new Fletcher16Context(),
|
||||
HashType.Fletcher32 => new Fletcher32Context(),
|
||||
HashType.MD5 => MD5.Create(),
|
||||
|
||||
Reference in New Issue
Block a user