diff --git a/SabreTools.Text.Extensions.Test/TextHelperTests.cs b/SabreTools.Text.Extensions.Test/TextHelperTests.cs
index 2a80f32..50490a2 100644
--- a/SabreTools.Text.Extensions.Test/TextHelperTests.cs
+++ b/SabreTools.Text.Extensions.Test/TextHelperTests.cs
@@ -65,6 +65,30 @@ namespace SabreTools.Text.Extensions.Test
#endregion
+ #region NormalizeCRC16
+
+ [Theory]
+ [InlineData(null, null)]
+ [InlineData("", "")]
+ [InlineData("-", "")]
+ [InlineData("_", "")]
+ [InlineData("0x", "")]
+ [InlineData("12", "0012")]
+ [InlineData("0x12", "0012")]
+ [InlineData("12ABC", "")]
+ [InlineData("0x12ABC", "")]
+ [InlineData("12AB", "12ab")]
+ [InlineData("0x12AB", "12ab")]
+ [InlineData("aceg", "")]
+ [InlineData("0xaceg", "")]
+ public void NormalizeCRC16Test(string? hash, string? expected)
+ {
+ string? actual = TextHelper.NormalizeCRC16(hash);
+ Assert.Equal(expected, actual);
+ }
+
+ #endregion
+
#region NormalizeCRC32
[Theory]
@@ -89,6 +113,30 @@ namespace SabreTools.Text.Extensions.Test
#endregion
+ #region NormalizeCRC64
+
+ [Theory]
+ [InlineData(null, null)]
+ [InlineData("", "")]
+ [InlineData("-", "")]
+ [InlineData("_", "")]
+ [InlineData("0x", "")]
+ [InlineData("1234", "0000000000001234")]
+ [InlineData("0x1234", "0000000000001234")]
+ [InlineData("1234ABCD1234ABCDE", "")]
+ [InlineData("0x1234ABCD1234ABCDE", "")]
+ [InlineData("1234ABCD1234ABCD", "1234abcd1234abcd")]
+ [InlineData("0x1234ABCD1234ABCD", "1234abcd1234abcd")]
+ [InlineData("abcdefghabcdefgh", "")]
+ [InlineData("0xabcdefghabcdefgh", "")]
+ public void NormalizeCRC64Test(string? hash, string? expected)
+ {
+ string? actual = TextHelper.NormalizeCRC64(hash);
+ Assert.Equal(expected, actual);
+ }
+
+ #endregion
+
#region NormalizeMD2
[Theory]
diff --git a/SabreTools.Text.Extensions/TextHelper.cs b/SabreTools.Text.Extensions/TextHelper.cs
index f359635..b48817b 100644
--- a/SabreTools.Text.Extensions/TextHelper.cs
+++ b/SabreTools.Text.Extensions/TextHelper.cs
@@ -70,12 +70,26 @@ namespace SabreTools.Text.Extensions
}
///
- /// Normalize a CRC32 string and pad to the correct size
+ /// Normalize a CRC-16 string and pad to the correct size
+ ///
+ /// 4 characters long
+ public static string? NormalizeCRC16(string? hash)
+ => NormalizeHashData(hash, 4);
+
+ ///
+ /// Normalize a CRC-32 string and pad to the correct size
///
/// 8 characters long
public static string? NormalizeCRC32(string? hash)
=> NormalizeHashData(hash, 8);
+ ///
+ /// Normalize a CRC-64 string and pad to the correct size
+ ///
+ /// 16 characters long
+ public static string? NormalizeCRC64(string? hash)
+ => NormalizeHashData(hash, 16);
+
///
/// Normalize a MD2 string and pad to the correct size
///
@@ -112,28 +126,28 @@ namespace SabreTools.Text.Extensions
=> NormalizeHashData(hash, 40);
///
- /// Normalize a SHA1 string and pad to the correct size
+ /// Normalize a SHA-1 string and pad to the correct size
///
/// 40 characters long
public static string? NormalizeSHA1(string? hash)
=> NormalizeHashData(hash, 40);
///
- /// Normalize a SHA256 string and pad to the correct size
+ /// Normalize a SHA-256 string and pad to the correct size
///
/// 64 characters long
public static string? NormalizeSHA256(string? hash)
=> NormalizeHashData(hash, 64);
///
- /// Normalize a SHA384 string and pad to the correct size
+ /// Normalize a SHA-384 string and pad to the correct size
///
/// 96 characters long
public static string? NormalizeSHA384(string? hash)
=> NormalizeHashData(hash, 96);
///
- /// Normalize a SHA512 string and pad to the correct size
+ /// Normalize a SHA-512 string and pad to the correct size
///
/// 128 characters long
public static string? NormalizeSHA512(string? hash)