mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Wire through MD2/MD4
This commit is contained in:
@@ -319,7 +319,8 @@ namespace SabreTools.Core
|
||||
string? otherSha1 = other.ReadString(Disk.SHA1Key);
|
||||
bool conditionalSha1 = Tools.Utilities.ConditionalHashEquals(selfSha1, otherSha1);
|
||||
|
||||
return conditionalMd5 && conditionalSha1;
|
||||
return conditionalMd5
|
||||
&& conditionalSha1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -352,7 +353,10 @@ namespace SabreTools.Core
|
||||
string? otherSpamSum = other.ReadString(Media.SpamSumKey);
|
||||
bool conditionalSpamSum = Tools.Utilities.ConditionalHashEquals(selfSpamSum, otherSpamSum);
|
||||
|
||||
return conditionalMd5 && conditionalSha1 && conditionalSha256 && conditionalSpamSum;
|
||||
return conditionalMd5
|
||||
&& conditionalSha1
|
||||
&& conditionalSha256
|
||||
&& conditionalSpamSum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -373,6 +377,14 @@ namespace SabreTools.Core
|
||||
string? otherCrc = other.ReadString(Rom.CRCKey);
|
||||
bool conditionalCrc = Tools.Utilities.ConditionalHashEquals(selfCrc, otherCrc);
|
||||
|
||||
string? selfMd2 = self.ReadString(Rom.MD2Key);
|
||||
string? otherMd2 = other.ReadString(Rom.MD2Key);
|
||||
bool conditionalMd2 = Tools.Utilities.ConditionalHashEquals(selfMd2, otherMd2);
|
||||
|
||||
string? selfMd4 = self.ReadString(Rom.MD4Key);
|
||||
string? otherMd4 = other.ReadString(Rom.MD4Key);
|
||||
bool conditionalMd4 = Tools.Utilities.ConditionalHashEquals(selfMd4, otherMd4);
|
||||
|
||||
string? selfMd5 = self.ReadString(Rom.MD5Key);
|
||||
string? otherMd5 = other.ReadString(Rom.MD5Key);
|
||||
bool conditionalMd5 = Tools.Utilities.ConditionalHashEquals(selfMd5, otherMd5);
|
||||
@@ -397,7 +409,15 @@ namespace SabreTools.Core
|
||||
string? otherSpamSum = other.ReadString(Rom.SpamSumKey);
|
||||
bool conditionalSpamSum = Tools.Utilities.ConditionalHashEquals(selfSpamSum, otherSpamSum);
|
||||
|
||||
return conditionalCrc && conditionalMd5 && conditionalSha1 && conditionalSha256 && conditionalSha384 && conditionalSha512 && conditionalSpamSum;
|
||||
return conditionalCrc
|
||||
&& conditionalMd2
|
||||
&& conditionalMd4
|
||||
&& conditionalMd5
|
||||
&& conditionalSha1
|
||||
&& conditionalSha256
|
||||
&& conditionalSha384
|
||||
&& conditionalSha512
|
||||
&& conditionalSpamSum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -439,7 +459,8 @@ namespace SabreTools.Core
|
||||
bool sha1Null = string.IsNullOrEmpty(self.ReadString(Disk.SHA1Key));
|
||||
sha1Null ^= string.IsNullOrEmpty(other.ReadString(Disk.SHA1Key));
|
||||
|
||||
return !md5Null || !sha1Null;
|
||||
return !md5Null
|
||||
|| !sha1Null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -459,7 +480,10 @@ namespace SabreTools.Core
|
||||
bool spamsumNull = string.IsNullOrEmpty(self.ReadString(Media.SpamSumKey));
|
||||
spamsumNull ^= string.IsNullOrEmpty(other.ReadString(Media.SpamSumKey));
|
||||
|
||||
return !md5Null || !sha1Null || !sha256Null || !spamsumNull;
|
||||
return !md5Null
|
||||
|| !sha1Null
|
||||
|| !sha256Null
|
||||
|| !spamsumNull;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -470,6 +494,12 @@ namespace SabreTools.Core
|
||||
bool crcNull = string.IsNullOrEmpty(self.ReadString(Rom.CRCKey));
|
||||
crcNull ^= string.IsNullOrEmpty(other.ReadString(Rom.CRCKey));
|
||||
|
||||
bool md2Null = string.IsNullOrEmpty(self.ReadString(Rom.MD2Key));
|
||||
md2Null ^= string.IsNullOrEmpty(other.ReadString(Rom.MD2Key));
|
||||
|
||||
bool md4Null = string.IsNullOrEmpty(self.ReadString(Rom.MD4Key));
|
||||
md4Null ^= string.IsNullOrEmpty(other.ReadString(Rom.MD4Key));
|
||||
|
||||
bool md5Null = string.IsNullOrEmpty(self.ReadString(Rom.MD5Key));
|
||||
md5Null ^= string.IsNullOrEmpty(other.ReadString(Rom.MD5Key));
|
||||
|
||||
@@ -488,7 +518,15 @@ namespace SabreTools.Core
|
||||
bool spamsumNull = string.IsNullOrEmpty(self.ReadString(Rom.SpamSumKey));
|
||||
spamsumNull ^= string.IsNullOrEmpty(other.ReadString(Rom.SpamSumKey));
|
||||
|
||||
return !crcNull || !md5Null || !sha1Null || !sha256Null || !sha384Null || !sha512Null || !spamsumNull;
|
||||
return !crcNull
|
||||
|| !md2Null
|
||||
|| !md4Null
|
||||
|| !md5Null
|
||||
|| !sha1Null
|
||||
|| !sha256Null
|
||||
|| !sha384Null
|
||||
|| !sha512Null
|
||||
|| !spamsumNull;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -499,7 +537,8 @@ namespace SabreTools.Core
|
||||
bool md5Null = string.IsNullOrEmpty(disk.ReadString(Disk.MD5Key));
|
||||
bool sha1Null = string.IsNullOrEmpty(disk.ReadString(Disk.SHA1Key));
|
||||
|
||||
return !md5Null || !sha1Null;
|
||||
return !md5Null
|
||||
|| !sha1Null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -512,7 +551,10 @@ namespace SabreTools.Core
|
||||
bool sha256Null = string.IsNullOrEmpty(media.ReadString(Media.SHA256Key));
|
||||
bool spamsumNull = string.IsNullOrEmpty(media.ReadString(Media.SpamSumKey));
|
||||
|
||||
return !md5Null || !sha1Null || !sha256Null || !spamsumNull;
|
||||
return !md5Null
|
||||
|| !sha1Null
|
||||
|| !sha256Null
|
||||
|| !spamsumNull;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -521,6 +563,8 @@ namespace SabreTools.Core
|
||||
private static bool HasHashes(this Rom rom)
|
||||
{
|
||||
bool crcNull = string.IsNullOrEmpty(rom.ReadString(Rom.CRCKey));
|
||||
bool md2Null = string.IsNullOrEmpty(rom.ReadString(Rom.MD2Key));
|
||||
bool md4Null = string.IsNullOrEmpty(rom.ReadString(Rom.MD4Key));
|
||||
bool md5Null = string.IsNullOrEmpty(rom.ReadString(Rom.MD5Key));
|
||||
bool sha1Null = string.IsNullOrEmpty(rom.ReadString(Rom.SHA1Key));
|
||||
bool sha256Null = string.IsNullOrEmpty(rom.ReadString(Rom.SHA256Key));
|
||||
@@ -528,7 +572,15 @@ namespace SabreTools.Core
|
||||
bool sha512Null = string.IsNullOrEmpty(rom.ReadString(Rom.SHA512Key));
|
||||
bool spamsumNull = string.IsNullOrEmpty(rom.ReadString(Rom.SpamSumKey));
|
||||
|
||||
return !crcNull || !md5Null || !sha1Null || !sha256Null || !sha384Null || !sha512Null || !spamsumNull;
|
||||
return !crcNull
|
||||
|| !md2Null
|
||||
|| !md4Null
|
||||
|| !md5Null
|
||||
|| !sha1Null
|
||||
|| !sha256Null
|
||||
|| !sha384Null
|
||||
|| !sha512Null
|
||||
|| !spamsumNull;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -542,7 +594,8 @@ namespace SabreTools.Core
|
||||
string? sha1 = disk.ReadString(Disk.SHA1Key);
|
||||
bool sha1Null = string.IsNullOrEmpty(sha1) || string.Equals(sha1, ZeroHash.SHA1Str, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return md5Null && sha1Null;
|
||||
return md5Null
|
||||
&& sha1Null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -562,7 +615,10 @@ namespace SabreTools.Core
|
||||
string? spamsum = media.ReadString(Media.SpamSumKey);
|
||||
bool spamsumNull = string.IsNullOrEmpty(spamsum) || string.Equals(spamsum, ZeroHash.SpamSumStr, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return md5Null && sha1Null && sha256Null && spamsumNull;
|
||||
return md5Null
|
||||
&& sha1Null
|
||||
&& sha256Null
|
||||
&& spamsumNull;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -573,6 +629,12 @@ namespace SabreTools.Core
|
||||
string? crc = rom.ReadString(Rom.CRCKey);
|
||||
bool crcNull = string.IsNullOrEmpty(crc) || string.Equals(crc, ZeroHash.CRC32Str, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
string? md2 = rom.ReadString(Rom.MD2Key);
|
||||
bool md2Null = string.IsNullOrEmpty(md2) || string.Equals(md2, ZeroHash.GetString(HashType.MD2), StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
string? md4 = rom.ReadString(Rom.MD4Key);
|
||||
bool md4Null = string.IsNullOrEmpty(md4) || string.Equals(md4, ZeroHash.GetString(HashType.MD4), StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
string? md5 = rom.ReadString(Rom.MD5Key);
|
||||
bool md5Null = string.IsNullOrEmpty(md5) || string.Equals(md5, ZeroHash.MD5Str, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
@@ -591,7 +653,15 @@ namespace SabreTools.Core
|
||||
string? spamsum = rom.ReadString(Rom.SpamSumKey);
|
||||
bool spamsumNull = string.IsNullOrEmpty(spamsum) || string.Equals(spamsum, ZeroHash.SpamSumStr, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return crcNull && md5Null && sha1Null && sha256Null && sha384Null && sha512Null && spamsumNull;
|
||||
return crcNull
|
||||
&& md2Null
|
||||
&& md4Null
|
||||
&& md5Null
|
||||
&& sha1Null
|
||||
&& sha256Null
|
||||
&& sha384Null
|
||||
&& sha512Null
|
||||
&& spamsumNull;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -686,6 +756,16 @@ namespace SabreTools.Core
|
||||
if (string.IsNullOrEmpty(selfCrc) && !string.IsNullOrEmpty(otherCrc))
|
||||
self[Rom.CRCKey] = otherCrc;
|
||||
|
||||
string? selfMd2 = self.ReadString(Rom.MD2Key);
|
||||
string? otherMd2 = other.ReadString(Rom.MD2Key);
|
||||
if (string.IsNullOrEmpty(selfMd2) && !string.IsNullOrEmpty(otherMd2))
|
||||
self[Rom.MD2Key] = otherMd2;
|
||||
|
||||
string? selfMd4 = self.ReadString(Rom.MD4Key);
|
||||
string? otherMd4 = other.ReadString(Rom.MD4Key);
|
||||
if (string.IsNullOrEmpty(selfMd4) && !string.IsNullOrEmpty(otherMd4))
|
||||
self[Rom.MD4Key] = otherMd4;
|
||||
|
||||
string? selfMd5 = self.ReadString(Rom.MD5Key);
|
||||
string? otherMd5 = other.ReadString(Rom.MD5Key);
|
||||
if (string.IsNullOrEmpty(selfMd5) && !string.IsNullOrEmpty(otherMd5))
|
||||
@@ -787,6 +867,14 @@ namespace SabreTools.Core
|
||||
if (!string.IsNullOrEmpty(crc))
|
||||
return $"_{crc}";
|
||||
|
||||
string? md2 = self.ReadString(Rom.MD2Key);
|
||||
if (!string.IsNullOrEmpty(md2))
|
||||
return $"_{md2}";
|
||||
|
||||
string? md4 = self.ReadString(Rom.MD4Key);
|
||||
if (!string.IsNullOrEmpty(md4))
|
||||
return $"_{md4}";
|
||||
|
||||
string? md5 = self.ReadString(Rom.MD5Key);
|
||||
if (!string.IsNullOrEmpty(md5))
|
||||
return $"_{md5}";
|
||||
|
||||
@@ -185,6 +185,16 @@ Features and Options:
|
||||
overrides the default hashing behavior of including CRC32, MD5, and
|
||||
SHA-1 hashes.
|
||||
|
||||
-md2, --include-md2 Include MD2 in output
|
||||
This enables MD2 calculation for each of the files. Adding this flag
|
||||
overrides the default hashing behavior of including CRC32, MD5, and
|
||||
SHA-1 hashes.
|
||||
|
||||
-md4, --include-md4 Include MD4 in output
|
||||
This enables MD4 calculation for each of the files. Adding this flag
|
||||
overrides the default hashing behavior of including CRC32, MD5, and
|
||||
SHA-1 hashes.
|
||||
|
||||
-md5, --include-md5 Include MD5 in output
|
||||
This enables MD5 calculation for each of the files. Adding this flag
|
||||
overrides the default hashing behavior of including CRC32, MD5, and
|
||||
@@ -248,6 +258,8 @@ Features and Options:
|
||||
lr, listrom - MAME Listrom
|
||||
lx, listxml - MAME Listxml
|
||||
miss, missfile - GoodTools Missfile
|
||||
md2 - MD2
|
||||
md4 - MD4
|
||||
md5 - MD5
|
||||
msx, openmsx - openMSX Software List
|
||||
ol, offlinelist - OfflineList XML
|
||||
@@ -559,6 +571,8 @@ Features and Options:
|
||||
lr, listrom - MAME Listrom
|
||||
lx, listxml - MAME Listxml
|
||||
miss, missfile - GoodTools Missfile
|
||||
md2 - MD2
|
||||
md4 - MD4
|
||||
md5 - MD5
|
||||
msx, openmsx - openMSX Software List
|
||||
ol, offlinelist - OfflineList XML
|
||||
@@ -610,7 +624,7 @@ Features and Options:
|
||||
For a DAT, or set of DATs, allow for splitting based on the best
|
||||
available hash for each file within. The order of preference for the
|
||||
outputted DATs is as follows: Nodump, SHA-512, SHA-384, SHA-256,
|
||||
SHA-1, MD5, CRC (or worse).
|
||||
SHA-1, MD5, MD4, MD2, CRC (or worse).
|
||||
|
||||
-ls, --level Split a SuperDAT or folder by lowest available level
|
||||
For a DAT, or set of DATs, allow for splitting based on the lowest
|
||||
@@ -724,6 +738,8 @@ Features and Options:
|
||||
lr, listrom - MAME Listrom
|
||||
lx, listxml - MAME Listxml
|
||||
miss, missfile - GoodTools Missfile
|
||||
md2 - MD2
|
||||
md4 - MD4
|
||||
md5 - MD5
|
||||
msx, openmsx - openMSX Software List
|
||||
ol, offlinelist - OfflineList XML
|
||||
@@ -755,6 +771,8 @@ Features and Options:
|
||||
- %publisher% - Replaced with game Publisher
|
||||
- %category% - Replaced with game Category
|
||||
- %crc% - Replaced with the CRC
|
||||
- %md2% - Replaced with the MD2
|
||||
- %md4% - Replaced with the MD4
|
||||
- %md5% - Replaced with the MD5
|
||||
- %sha1% - Replaced with the SHA-1
|
||||
- %sha256% - Replaced with the SHA-256
|
||||
|
||||
@@ -33,6 +33,20 @@ namespace SabreTools.Core.Tools
|
||||
public static string? NormalizeCRC32(string? hash)
|
||||
=> NormalizeHashData(hash, Constants.CRCLength);
|
||||
|
||||
/// <summary>
|
||||
/// Normalize a MD2 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <remarks>MD2 is the same length as MD5</remarks>
|
||||
public static string? NormalizeMD2(string? hash)
|
||||
=> NormalizeHashData(hash, Constants.MD5Length);
|
||||
|
||||
/// <summary>
|
||||
/// Normalize a MD4 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <remarks>MD4 is the same length as MD5</remarks>
|
||||
public static string? NormalizeMD4(string? hash)
|
||||
=> NormalizeHashData(hash, Constants.MD5Length);
|
||||
|
||||
/// <summary>
|
||||
/// Normalize a MD5 string and pad to the correct size
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user