Update Hashing to 1.2.3

This commit is contained in:
Matt Nadareski
2024-11-06 21:56:44 -05:00
parent e302dfccf1
commit 20153f62cf
5 changed files with 79 additions and 27 deletions

View File

@@ -235,10 +235,18 @@ namespace SabreTools.Serialization.Test
[Theory]
[InlineData("test-sfv-files.sfv", HashType.CRC32, 100)]
[InlineData("test-sfv-files.sfv", HashType.CRC32_ISO, 100)]
[InlineData("test-sfv-files.sfv", HashType.CRC32_Naive, 100)]
[InlineData("test-sfv-files.sfv", HashType.CRC32_Optimized, 100)]
[InlineData("test-sfv-files.sfv", HashType.CRC32_Parallel, 100)]
[InlineData("test-sfv-files.sfv", HashType.CRC32_AIXM, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_AUTOSAR, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_BASE91D, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_BZIP2, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_CDROMEDC, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_CKSUM, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_ISCSI, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_ISOHDLC, 100)]
[InlineData("test-sfv-files.sfv", HashType.CRC32_JAMCRC, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_MEF, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_MPEG2, 100)] // Not technically the same as normal CRC-32
[InlineData("test-sfv-files.sfv", HashType.CRC32_XFER, 100)] // Not technically the same as normal CRC-32
[InlineData("test-md5-files.md5", HashType.MD5, 100)]
[InlineData("test-sha1-files.sha1", HashType.SHA1, 100)]
[InlineData("test-sha256.sha256", HashType.SHA256, 1)]
@@ -259,10 +267,18 @@ namespace SabreTools.Serialization.Test
switch (hash)
{
case HashType.CRC32:
case HashType.CRC32_ISO:
case HashType.CRC32_Naive:
case HashType.CRC32_Optimized:
case HashType.CRC32_Parallel:
case HashType.CRC32_AIXM:
case HashType.CRC32_AUTOSAR:
case HashType.CRC32_BASE91D:
case HashType.CRC32_BZIP2:
case HashType.CRC32_CDROMEDC:
case HashType.CRC32_CKSUM:
case HashType.CRC32_ISCSI:
case HashType.CRC32_ISOHDLC:
case HashType.CRC32_JAMCRC:
case HashType.CRC32_MEF:
case HashType.CRC32_MPEG2:
case HashType.CRC32_XFER:
Assert.NotNull(dat.SFV);
Assert.Equal(count, dat.SFV.Length);
break;

View File

@@ -102,12 +102,24 @@ namespace SabreTools.Serialization.CrossModel
return new Models.Hashfile.Hashfile
{
SFV = hash == HashType.CRC32 || hash == HashType.CRC32_ISO || hash == HashType.CRC32_Naive || hash == HashType.CRC32_Optimized || hash == HashType.CRC32_Parallel
? roms
.Where(r => r != null)
.Select(ConvertToSFV)
.ToArray()
: null,
SFV = hash == HashType.CRC32
|| hash == HashType.CRC32_AIXM
|| hash == HashType.CRC32_AUTOSAR
|| hash == HashType.CRC32_BASE91D
|| hash == HashType.CRC32_BZIP2
|| hash == HashType.CRC32_CDROMEDC
|| hash == HashType.CRC32_CKSUM
|| hash == HashType.CRC32_ISCSI
|| hash == HashType.CRC32_ISOHDLC
|| hash == HashType.CRC32_JAMCRC
|| hash == HashType.CRC32_MEF
|| hash == HashType.CRC32_MPEG2
|| hash == HashType.CRC32_XFER
? roms
.Where(r => r != null)
.Select(ConvertToSFV)
.ToArray()
: null,
MD5 = hash == HashType.MD5
? roms
.Where(r => r != null)

View File

@@ -106,10 +106,18 @@ namespace SabreTools.Serialization.Deserializers
switch (hash)
{
case HashType.CRC32:
case HashType.CRC32_ISO:
case HashType.CRC32_Naive:
case HashType.CRC32_Optimized:
case HashType.CRC32_Parallel:
case HashType.CRC32_AIXM:
case HashType.CRC32_AUTOSAR:
case HashType.CRC32_BASE91D:
case HashType.CRC32_BZIP2:
case HashType.CRC32_CDROMEDC:
case HashType.CRC32_CKSUM:
case HashType.CRC32_ISCSI:
case HashType.CRC32_ISOHDLC:
case HashType.CRC32_JAMCRC:
case HashType.CRC32_MEF:
case HashType.CRC32_MPEG2:
case HashType.CRC32_XFER:
var sfv = new SFV
{
#if NETFRAMEWORK
@@ -201,10 +209,18 @@ namespace SabreTools.Serialization.Deserializers
switch (hash)
{
case HashType.CRC32:
case HashType.CRC32_ISO:
case HashType.CRC32_Naive:
case HashType.CRC32_Optimized:
case HashType.CRC32_Parallel:
case HashType.CRC32_AIXM:
case HashType.CRC32_AUTOSAR:
case HashType.CRC32_BASE91D:
case HashType.CRC32_BZIP2:
case HashType.CRC32_CDROMEDC:
case HashType.CRC32_CKSUM:
case HashType.CRC32_ISCSI:
case HashType.CRC32_ISOHDLC:
case HashType.CRC32_JAMCRC:
case HashType.CRC32_MEF:
case HashType.CRC32_MPEG2:
case HashType.CRC32_XFER:
dat.SFV = hashes.Cast<SFV>().ToArray();
break;
case HashType.MD5:

View File

@@ -45,7 +45,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.ASN1" Version="1.3.3" />
<PackageReference Include="SabreTools.Hashing" Version="1.2.2" />
<PackageReference Include="SabreTools.Hashing" Version="1.2.3" />
<PackageReference Include="SabreTools.IO" Version="1.4.13" />
<PackageReference Include="SabreTools.Models" Version="1.4.11" />
</ItemGroup>

View File

@@ -101,10 +101,18 @@ namespace SabreTools.Serialization.Serializers
switch (hash)
{
case HashType.CRC32:
case HashType.CRC32_ISO:
case HashType.CRC32_Naive:
case HashType.CRC32_Optimized:
case HashType.CRC32_Parallel:
case HashType.CRC32_AIXM:
case HashType.CRC32_AUTOSAR:
case HashType.CRC32_BASE91D:
case HashType.CRC32_BZIP2:
case HashType.CRC32_CDROMEDC:
case HashType.CRC32_CKSUM:
case HashType.CRC32_ISCSI:
case HashType.CRC32_ISOHDLC:
case HashType.CRC32_JAMCRC:
case HashType.CRC32_MEF:
case HashType.CRC32_MPEG2:
case HashType.CRC32_XFER:
WriteSFV(obj.SFV, writer);
break;
case HashType.MD5: