diff --git a/IRDKit/IRDKit.csproj b/IRDKit/IRDKit.csproj index a2d15f2..186cf7b 100644 --- a/IRDKit/IRDKit.csproj +++ b/IRDKit/IRDKit.csproj @@ -5,7 +5,7 @@ Exe irdkit irdkit - net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 + net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 false latest @@ -30,7 +30,7 @@ - + diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs index 8cf8841..af415db 100644 --- a/IRDKit/Program.cs +++ b/IRDKit/Program.cs @@ -933,8 +933,12 @@ namespace IRDKit Console.WriteLine("No key provided... Searching for key on redump.org"); // Compute CRC32 hash - string crc32String = HashTool.GetFileHash(isoPath, HashType.CRC32); // TODO: Output byte[] once ST.Hashing supports it - uint crc32UInt = BitConverter.ToUInt32(LibIRD.IRD.HexStringToByteArray(crc32String), 0); + byte[] crc32 = HashTool.GetFileHashArray(isoPath, HashType.CRC32); + 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 #if !NETFRAMEWORK diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index 9f968a6..b333b68 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -804,11 +804,11 @@ namespace LibIRD // Begin a GZip stream to write header to using MemoryStream headerStream = new(); #if NET6_0_OR_GREATER - using GZipStream gzStream = new(headerStream, CompressionLevel.SmallestSize); + using (GZipStream gzStream = new(headerStream, CompressionLevel.SmallestSize)) #elif NETCOREAPP || NET45_OR_GREATER - using GZipStream gzStream = new(headerStream, CompressionLevel.Optimal); + using (GZipStream gzStream = new(headerStream, CompressionLevel.Optimal)) #else - using GZipStream gzStream = new(headerStream, CompressionMode.Compress); + using (GZipStream gzStream = new(headerStream, CompressionMode.Compress)) #endif { // Start reading data from the beginning of the ISO file @@ -838,11 +838,11 @@ namespace LibIRD // Begin a GZip stream to write footer to using MemoryStream footerStream = new(); #if NET6_0_OR_GREATER - using GZipStream gzStream = new(footerStream, CompressionLevel.SmallestSize); + using (GZipStream gzStream = new(footerStream, CompressionLevel.SmallestSize)) #elif NETCOREAPP || NET45_OR_GREATER - using GZipStream gzStream = new(footerStream, CompressionLevel.Optimal); + using (GZipStream gzStream = new(footerStream, CompressionLevel.Optimal)) #else - using GZipStream gzStream = new(footerStream, CompressionMode.Compress); + using (GZipStream gzStream = new(footerStream, CompressionMode.Compress)) #endif { // Start reading data from after last file (PS3UPDAT.PUP) @@ -1084,6 +1084,7 @@ namespace LibIRD if (redump) { crc32 = isoHasher.CurrentHashBytes; + Array.Reverse(crc32); UID = BitConverter.ToUInt32(crc32, 0); } return; @@ -1340,8 +1341,8 @@ namespace LibIRD // Calculate the little-endian 32-bit "IEEE 802.3" CRC value of the IRD contents so far stream.Position = 0; - string crc32String = HashTool.GetStreamHash(stream, HashType.CRC32); - byte[] crc32 = HexStringToByteArray(crc32String); + byte[] crc32 = HashTool.GetStreamHashArray(stream, HashType.CRC32, true); + Array.Reverse(crc32); // Write final CRC value to the stream stream.Write(crc32, 0, 4); diff --git a/LibIRD/LibIRD.csproj b/LibIRD/LibIRD.csproj index 27ade3a..3f8c772 100644 --- a/LibIRD/LibIRD.csproj +++ b/LibIRD/LibIRD.csproj @@ -2,7 +2,7 @@ - net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 + net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 false latest @@ -29,7 +29,7 @@ - +