mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFiles/] Clean all hash data
This commit is contained in:
@@ -466,68 +466,68 @@ namespace SabreTools.Library.DatFiles
|
||||
if (item.Type == ItemType.Rom)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Rom)item).CRC = quoteless.ToLowerInvariant();
|
||||
((Rom)item).CRC = Utilities.CleanHashData(quoteless, Constants.CRCLength);
|
||||
}
|
||||
break;
|
||||
case "md5":
|
||||
if (item.Type == ItemType.Rom)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Rom)item).MD5 = quoteless.ToLowerInvariant();
|
||||
((Rom)item).MD5 = Utilities.CleanHashData(quoteless, Constants.MD5Length);
|
||||
}
|
||||
else if (item.Type == ItemType.Disk)
|
||||
{
|
||||
i++;
|
||||
quoteless = linegc[i].Replace("\"", "");
|
||||
((Disk)item).MD5 = quoteless.ToLowerInvariant();
|
||||
((Disk)item).MD5 = Utilities.CleanHashData(quoteless, Constants.MD5Length);
|
||||
}
|
||||
break;
|
||||
case "sha1":
|
||||
if (item.Type == ItemType.Rom)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Rom)item).SHA1 = quoteless.ToLowerInvariant();
|
||||
((Rom)item).SHA1 = Utilities.CleanHashData(quoteless, Constants.SHA1Length);
|
||||
}
|
||||
else if (item.Type == ItemType.Disk)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Disk)item).SHA1 = quoteless.ToLowerInvariant();
|
||||
((Disk)item).SHA1 = Utilities.CleanHashData(quoteless, Constants.SHA1Length);
|
||||
}
|
||||
break;
|
||||
case "sha256":
|
||||
if (item.Type == ItemType.Rom)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Rom)item).SHA256 = quoteless.ToLowerInvariant();
|
||||
((Rom)item).SHA256 = Utilities.CleanHashData(quoteless, Constants.SHA256Length);
|
||||
}
|
||||
else if (item.Type == ItemType.Disk)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Disk)item).SHA256 = quoteless.ToLowerInvariant();
|
||||
((Disk)item).SHA256 = Utilities.CleanHashData(quoteless, Constants.SHA256Length);
|
||||
}
|
||||
break;
|
||||
case "sha384":
|
||||
if (item.Type == ItemType.Rom)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Rom)item).SHA384 = quoteless.ToLowerInvariant();
|
||||
((Rom)item).SHA384 = Utilities.CleanHashData(quoteless, Constants.SHA384Length);
|
||||
}
|
||||
else if (item.Type == ItemType.Disk)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Disk)item).SHA384 = quoteless.ToLowerInvariant();
|
||||
((Disk)item).SHA384 = Utilities.CleanHashData(quoteless, Constants.SHA384Length);
|
||||
}
|
||||
break;
|
||||
case "sha512":
|
||||
if (item.Type == ItemType.Rom)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Rom)item).SHA512 = quoteless.ToLowerInvariant();
|
||||
((Rom)item).SHA512 = Utilities.CleanHashData(quoteless, Constants.SHA512Length);
|
||||
}
|
||||
else if (item.Type == ItemType.Disk)
|
||||
{
|
||||
quoteless = linegc[++i].Replace("\"", "");
|
||||
((Disk)item).SHA512 = quoteless.ToLowerInvariant();
|
||||
((Disk)item).SHA512 = Utilities.CleanHashData(quoteless, Constants.SHA512Length);
|
||||
}
|
||||
break;
|
||||
case "status":
|
||||
|
||||
@@ -88,12 +88,12 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = name,
|
||||
Size = -1,
|
||||
CRC = ((_hash & Hash.CRC) != 0 ? hash : null),
|
||||
MD5 = ((_hash & Hash.MD5) != 0 ? hash : null),
|
||||
SHA1 = ((_hash & Hash.SHA1) != 0 ? hash : null),
|
||||
SHA256 = ((_hash & Hash.SHA256) != 0 ? hash : null),
|
||||
SHA384 = ((_hash & Hash.SHA384) != 0 ? hash : null),
|
||||
SHA512 = ((_hash & Hash.SHA512) != 0 ? hash : null),
|
||||
CRC = ((_hash & Hash.CRC) != 0 ? Utilities.CleanHashData(hash, Constants.CRCLength) : null),
|
||||
MD5 = ((_hash & Hash.MD5) != 0 ? Utilities.CleanHashData(hash, Constants.MD5Length) : null),
|
||||
SHA1 = ((_hash & Hash.SHA1) != 0 ? Utilities.CleanHashData(hash, Constants.SHA1Length) : null),
|
||||
SHA256 = ((_hash & Hash.SHA256) != 0 ? Utilities.CleanHashData(hash, Constants.SHA256Length) : null),
|
||||
SHA384 = ((_hash & Hash.SHA384) != 0 ? Utilities.CleanHashData(hash, Constants.SHA384Length) : null),
|
||||
SHA512 = ((_hash & Hash.SHA512) != 0 ? Utilities.CleanHashData(hash, Constants.SHA512Length) : null),
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
MachineName = Path.GetFileNameWithoutExtension(filename),
|
||||
|
||||
@@ -239,12 +239,12 @@ namespace SabreTools.Library.DatFiles
|
||||
Name = reader.GetAttribute("name"),
|
||||
Bios = reader.GetAttribute("bios"),
|
||||
Size = Utilities.GetSize(reader.GetAttribute("size")),
|
||||
CRC = reader.GetAttribute("crc")?.ToLowerInvariant(),
|
||||
MD5 = reader.GetAttribute("md5")?.ToLowerInvariant(),
|
||||
SHA1 = reader.GetAttribute("sha1")?.ToLowerInvariant(),
|
||||
SHA256 = reader.GetAttribute("sha256")?.ToLowerInvariant(),
|
||||
SHA384 = reader.GetAttribute("sha384")?.ToLowerInvariant(),
|
||||
SHA512 = reader.GetAttribute("sha512")?.ToLowerInvariant(),
|
||||
CRC = Utilities.CleanHashData(reader.GetAttribute("crc"), Constants.CRCLength),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
MergeTag = reader.GetAttribute("merge"),
|
||||
Region = reader.GetAttribute("region"),
|
||||
Offset = reader.GetAttribute("offset"),
|
||||
@@ -269,11 +269,11 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem disk = new Disk
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5")?.ToLowerInvariant(),
|
||||
SHA1 = reader.GetAttribute("sha1")?.ToLowerInvariant(),
|
||||
SHA256 = reader.GetAttribute("sha256")?.ToLowerInvariant(),
|
||||
SHA384 = reader.GetAttribute("sha384")?.ToLowerInvariant(),
|
||||
SHA512 = reader.GetAttribute("sha512")?.ToLowerInvariant(),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
MergeTag = reader.GetAttribute("merge"),
|
||||
Region = reader.GetAttribute("region"),
|
||||
Index = reader.GetAttribute("index"),
|
||||
|
||||
@@ -439,12 +439,12 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Size = Utilities.GetSize(reader.GetAttribute("size")),
|
||||
CRC = reader.GetAttribute("crc")?.ToLowerInvariant(),
|
||||
MD5 = reader.GetAttribute("md5")?.ToLowerInvariant(),
|
||||
SHA1 = reader.GetAttribute("sha1")?.ToLowerInvariant(),
|
||||
SHA256 = reader.GetAttribute("sha256")?.ToLowerInvariant(),
|
||||
SHA384 = reader.GetAttribute("sha384")?.ToLowerInvariant(),
|
||||
SHA512 = reader.GetAttribute("sha512")?.ToLowerInvariant(),
|
||||
CRC = Utilities.CleanHashData(reader.GetAttribute("crc"), Constants.CRCLength),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
MergeTag = reader.GetAttribute("merge"),
|
||||
ItemStatus = Utilities.GetItemStatus(reader.GetAttribute("status")),
|
||||
Date = Utilities.GetDate(reader.GetAttribute("date")),
|
||||
@@ -467,11 +467,11 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem disk = new Disk
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5")?.ToLowerInvariant(),
|
||||
SHA1 = reader.GetAttribute("sha1")?.ToLowerInvariant(),
|
||||
SHA256 = reader.GetAttribute("sha256")?.ToLowerInvariant(),
|
||||
SHA384 = reader.GetAttribute("sha384")?.ToLowerInvariant(),
|
||||
SHA512 = reader.GetAttribute("sha512")?.ToLowerInvariant(),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
MergeTag = reader.GetAttribute("merge"),
|
||||
ItemStatus = Utilities.GetItemStatus(reader.GetAttribute("status")),
|
||||
|
||||
|
||||
@@ -740,7 +740,7 @@ namespace SabreTools.Library.DatFiles
|
||||
roms.Add(new Rom()
|
||||
{
|
||||
Name = (releaseNumber != "0" ? releaseNumber + " - " : "") + machineName + pair.Item1,
|
||||
CRC = pair.Item2,
|
||||
CRC = Utilities.CleanHashData(pair.Item2, Constants.CRCLength),
|
||||
|
||||
ItemStatus = ItemStatus.None,
|
||||
});
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = rominfo[5],
|
||||
Size = size,
|
||||
CRC = rominfo[6],
|
||||
CRC = Utilities.CleanHashData(rominfo[6], Constants.CRCLength),
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
MachineName = rominfo[3],
|
||||
|
||||
@@ -405,11 +405,11 @@ namespace SabreTools.Library.DatFiles
|
||||
datItem = new Disk
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5")?.ToLowerInvariant(),
|
||||
SHA1 = reader.GetAttribute("sha1")?.ToLowerInvariant(),
|
||||
SHA256 = reader.GetAttribute("sha256")?.ToLowerInvariant(),
|
||||
SHA384 = reader.GetAttribute("sha384")?.ToLowerInvariant(),
|
||||
SHA512 = reader.GetAttribute("sha512")?.ToLowerInvariant(),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
ItemStatus = its,
|
||||
|
||||
SystemID = sysid,
|
||||
@@ -436,12 +436,12 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Size = size,
|
||||
CRC = reader.GetAttribute("crc")?.ToLowerInvariant(),
|
||||
MD5 = reader.GetAttribute("md5")?.ToLowerInvariant(),
|
||||
SHA1 = reader.GetAttribute("sha1")?.ToLowerInvariant(),
|
||||
SHA256 = reader.GetAttribute("sha256")?.ToLowerInvariant(),
|
||||
SHA384 = reader.GetAttribute("sha384")?.ToLowerInvariant(),
|
||||
SHA512 = reader.GetAttribute("sha512")?.ToLowerInvariant(),
|
||||
CRC = Utilities.CleanHashData(reader.GetAttribute("crc"), Constants.CRCLength),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
ItemStatus = its,
|
||||
Date = date,
|
||||
|
||||
|
||||
@@ -217,22 +217,22 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
break;
|
||||
case "DatItem.CRC":
|
||||
crc = value;
|
||||
crc = Utilities.CleanHashData(value, Constants.CRCLength);
|
||||
break;
|
||||
case "DatItem.MD5":
|
||||
md5 = value;
|
||||
md5 = Utilities.CleanHashData(value, Constants.MD5Length);
|
||||
break;
|
||||
case "DatItem.SHA1":
|
||||
sha1 = value;
|
||||
sha1 = Utilities.CleanHashData(value, Constants.SHA1Length);
|
||||
break;
|
||||
case "DatItem.SHA256":
|
||||
sha256 = value;
|
||||
sha256 = Utilities.CleanHashData(value, Constants.SHA256Length);
|
||||
break;
|
||||
case "DatItem.SHA384":
|
||||
sha384 = value;
|
||||
sha384 = Utilities.CleanHashData(value, Constants.SHA384Length);
|
||||
break;
|
||||
case "DatItem.SHA512":
|
||||
sha512 = value;
|
||||
sha512 = Utilities.CleanHashData(value, Constants.SHA512Length);
|
||||
break;
|
||||
case "DatItem.Nodump":
|
||||
status = Utilities.GetItemStatus(value);
|
||||
|
||||
@@ -434,12 +434,12 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Size = Utilities.GetSize(reader.GetAttribute("size")),
|
||||
CRC = reader.GetAttribute("crc")?.ToLowerInvariant(),
|
||||
MD5 = reader.GetAttribute("md5")?.ToLowerInvariant(),
|
||||
SHA1 = reader.GetAttribute("sha1")?.ToLowerInvariant(),
|
||||
SHA256 = reader.GetAttribute("sha256")?.ToLowerInvariant(),
|
||||
SHA384 = reader.GetAttribute("sha384")?.ToLowerInvariant(),
|
||||
SHA512 = reader.GetAttribute("sha512")?.ToLowerInvariant(),
|
||||
CRC = Utilities.CleanHashData(reader.GetAttribute("crc"), Constants.CRCLength),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
Offset = reader.GetAttribute("offset"),
|
||||
// Value = reader.GetAttribute("value");
|
||||
ItemStatus = Utilities.GetItemStatus(reader.GetAttribute("status")),
|
||||
@@ -529,11 +529,11 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem disk = new Disk
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5")?.ToLowerInvariant(),
|
||||
SHA1 = reader.GetAttribute("sha1")?.ToLowerInvariant(),
|
||||
SHA256 = reader.GetAttribute("sha256")?.ToLowerInvariant(),
|
||||
SHA384 = reader.GetAttribute("sha384")?.ToLowerInvariant(),
|
||||
SHA512 = reader.GetAttribute("sha512")?.ToLowerInvariant(),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
ItemStatus = Utilities.GetItemStatus(reader.GetAttribute("status")),
|
||||
Writable = Utilities.GetYesNo(reader.GetAttribute("writable")),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user