Use ST.Hashing for SHA1

This commit is contained in:
Deterous
2024-03-05 15:15:40 +09:00
parent 0dbc483a91
commit e8f4d88711
3 changed files with 10 additions and 45 deletions
-29
View File
@@ -1,6 +1,5 @@
using System;
using System.IO;
using SabreTools.Hashing;
namespace LibIRD
{
@@ -231,34 +230,6 @@ namespace LibIRD
return pic;
}
/// <summary>
/// Generates the UID field by computing the CRC32 hash of the ISO
/// </summary>
/// <param name="isoPath">Path to the ISO</param>
/// <exception cref="FileNotFoundException"></exception>
private static uint GenerateUID(string isoPath)
{
// Check file exists
FileInfo iso;
try
{
iso = new FileInfo(isoPath);
}
catch (Exception e)
{
throw new ArgumentException("Invalid ISO Path: " + e.Message);
}
if (!iso.Exists)
throw new FileNotFoundException(nameof(isoPath));
// Compute CRC32 hash
string crc32String = HashTool.GetFileHash(isoPath, HashType.CRC32); // TODO: Output byte[] once ST.Hashing supports it
byte[] crc32 = HexStringToByteArray(crc32String);
// Redump ISO CRC32 hash is used as the Unique ID in the reproducible IRD
return BitConverter.ToUInt32(crc32, 0);
}
/// <summary>
/// Calculates ISO file size
/// </summary>