Update ST.Hashing version

This commit is contained in:
Deterous
2024-03-06 12:09:15 +09:00
parent 1886e14a9b
commit d585c4b534
4 changed files with 19 additions and 14 deletions
+2 -2
View File
@@ -5,7 +5,7 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetName>irdkit</TargetName> <TargetName>irdkit</TargetName>
<AssemblyName>irdkit</AssemblyName> <AssemblyName>irdkit</AssemblyName>
<TargetFrameworks>net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks> <TargetFrameworks>net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers> <RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<CheckEolTargetFramework>false</CheckEolTargetFramework> <CheckEolTargetFramework>false</CheckEolTargetFramework>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
@@ -30,7 +30,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" /> <PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="SabreTools.Hashing" Version="1.1.2" /> <PackageReference Include="SabreTools.Hashing" Version="1.1.3" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.4" /> <PackageReference Include="SabreTools.RedumpLib" Version="1.3.4" />
</ItemGroup> </ItemGroup>
+6 -2
View File
@@ -933,8 +933,12 @@ namespace IRDKit
Console.WriteLine("No key provided... Searching for key on redump.org"); Console.WriteLine("No key provided... Searching for key on redump.org");
// Compute CRC32 hash // Compute CRC32 hash
string crc32String = HashTool.GetFileHash(isoPath, HashType.CRC32); // TODO: Output byte[] once ST.Hashing supports it byte[] crc32 = HashTool.GetFileHashArray(isoPath, HashType.CRC32);
uint crc32UInt = BitConverter.ToUInt32(LibIRD.IRD.HexStringToByteArray(crc32String), 0); string crc32String = LibIRD.IRD.ByteArrayToHexString(crc32).ToLowerInvariant();
// Convert to UInt for use as UID in IRD
Array.Reverse(crc32);
uint crc32UInt = BitConverter.ToUInt32(crc32, 0);
// Search for ISO on redump.org // Search for ISO on redump.org
#if !NETFRAMEWORK #if !NETFRAMEWORK
+9 -8
View File
@@ -804,11 +804,11 @@ namespace LibIRD
// Begin a GZip stream to write header to // Begin a GZip stream to write header to
using MemoryStream headerStream = new(); using MemoryStream headerStream = new();
#if NET6_0_OR_GREATER #if NET6_0_OR_GREATER
using GZipStream gzStream = new(headerStream, CompressionLevel.SmallestSize); using (GZipStream gzStream = new(headerStream, CompressionLevel.SmallestSize))
#elif NETCOREAPP || NET45_OR_GREATER #elif NETCOREAPP || NET45_OR_GREATER
using GZipStream gzStream = new(headerStream, CompressionLevel.Optimal); using (GZipStream gzStream = new(headerStream, CompressionLevel.Optimal))
#else #else
using GZipStream gzStream = new(headerStream, CompressionMode.Compress); using (GZipStream gzStream = new(headerStream, CompressionMode.Compress))
#endif #endif
{ {
// Start reading data from the beginning of the ISO file // Start reading data from the beginning of the ISO file
@@ -838,11 +838,11 @@ namespace LibIRD
// Begin a GZip stream to write footer to // Begin a GZip stream to write footer to
using MemoryStream footerStream = new(); using MemoryStream footerStream = new();
#if NET6_0_OR_GREATER #if NET6_0_OR_GREATER
using GZipStream gzStream = new(footerStream, CompressionLevel.SmallestSize); using (GZipStream gzStream = new(footerStream, CompressionLevel.SmallestSize))
#elif NETCOREAPP || NET45_OR_GREATER #elif NETCOREAPP || NET45_OR_GREATER
using GZipStream gzStream = new(footerStream, CompressionLevel.Optimal); using (GZipStream gzStream = new(footerStream, CompressionLevel.Optimal))
#else #else
using GZipStream gzStream = new(footerStream, CompressionMode.Compress); using (GZipStream gzStream = new(footerStream, CompressionMode.Compress))
#endif #endif
{ {
// Start reading data from after last file (PS3UPDAT.PUP) // Start reading data from after last file (PS3UPDAT.PUP)
@@ -1084,6 +1084,7 @@ namespace LibIRD
if (redump) if (redump)
{ {
crc32 = isoHasher.CurrentHashBytes; crc32 = isoHasher.CurrentHashBytes;
Array.Reverse(crc32);
UID = BitConverter.ToUInt32(crc32, 0); UID = BitConverter.ToUInt32(crc32, 0);
} }
return; return;
@@ -1340,8 +1341,8 @@ namespace LibIRD
// Calculate the little-endian 32-bit "IEEE 802.3" CRC value of the IRD contents so far // Calculate the little-endian 32-bit "IEEE 802.3" CRC value of the IRD contents so far
stream.Position = 0; stream.Position = 0;
string crc32String = HashTool.GetStreamHash(stream, HashType.CRC32); byte[] crc32 = HashTool.GetStreamHashArray(stream, HashType.CRC32, true);
byte[] crc32 = HexStringToByteArray(crc32String); Array.Reverse(crc32);
// Write final CRC value to the stream // Write final CRC value to the stream
stream.Write(crc32, 0, 4); stream.Write(crc32, 0, 4);
+2 -2
View File
@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<!-- Assembly Properties --> <!-- Assembly Properties -->
<TargetFrameworks>net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks> <TargetFrameworks>net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers> <RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<CheckEolTargetFramework>false</CheckEolTargetFramework> <CheckEolTargetFramework>false</CheckEolTargetFramework>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
@@ -29,7 +29,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.Hashing" Version="1.1.2" /> <PackageReference Include="SabreTools.Hashing" Version="1.1.3" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith(`netcoreapp3`)) OR $(TargetFramework.StartsWith(`net5`))"> <ItemGroup Condition="$(TargetFramework.StartsWith(`netcoreapp3`)) OR $(TargetFramework.StartsWith(`net5`))">