distinguish between SHA1/MD5/CRC32 in header hash
This commit is contained in:
parent
296145ba2d
commit
03cdb4cdf3
|
@ -15,6 +15,8 @@ namespace BizHawk.Client.Common
|
||||||
public const string StartsFromSaveram = "StartsFromSaveRam";
|
public const string StartsFromSaveram = "StartsFromSaveRam";
|
||||||
public const string SavestateBinaryBase64Blob = "SavestateBinaryBase64Blob"; // this string will not contain base64: ; it's implicit (this is to avoid another big string op to dice off the base64: substring)
|
public const string SavestateBinaryBase64Blob = "SavestateBinaryBase64Blob"; // this string will not contain base64: ; it's implicit (this is to avoid another big string op to dice off the base64: substring)
|
||||||
public const string Sha1 = "SHA1";
|
public const string Sha1 = "SHA1";
|
||||||
|
public const string Md5 = "MD5";
|
||||||
|
public const string Crc32 = "CRC32";
|
||||||
public const string FirmwareSha1 = "FirmwareSHA1";
|
public const string FirmwareSha1 = "FirmwareSHA1";
|
||||||
public const string Pal = "PAL";
|
public const string Pal = "PAL";
|
||||||
public const string BoardName = "BoardName";
|
public const string BoardName = "BoardName";
|
||||||
|
|
|
@ -108,13 +108,49 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public string Hash
|
public string Hash
|
||||||
{
|
{
|
||||||
get => Header[HeaderKeys.Sha1];
|
get
|
||||||
|
{
|
||||||
|
if (Header[HeaderKeys.Sha1] != string.Empty)
|
||||||
|
{
|
||||||
|
return Header[HeaderKeys.Sha1];
|
||||||
|
}
|
||||||
|
else if (Header[HeaderKeys.Md5] != string.Empty)
|
||||||
|
{
|
||||||
|
return Header[HeaderKeys.Md5];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Header[HeaderKeys.Crc32];
|
||||||
|
}
|
||||||
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (Header[HeaderKeys.Sha1] != value)
|
if (value.Length == 40)
|
||||||
{
|
{
|
||||||
Changes = true;
|
if (Header[HeaderKeys.Sha1] != value || Header[HeaderKeys.Md5] != string.Empty || Header[HeaderKeys.Crc32] != string.Empty)
|
||||||
Header[HeaderKeys.Sha1] = value;
|
{
|
||||||
|
Changes = true;
|
||||||
|
Header[HeaderKeys.Sha1] = value;
|
||||||
|
Header[HeaderKeys.Md5] = Header[HeaderKeys.Crc32] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (value.Length == 32)
|
||||||
|
{
|
||||||
|
if (Header[HeaderKeys.Md5] != value || Header[HeaderKeys.Sha1] != string.Empty || Header[HeaderKeys.Crc32] != string.Empty)
|
||||||
|
{
|
||||||
|
Changes = true;
|
||||||
|
Header[HeaderKeys.Md5] = value;
|
||||||
|
Header[HeaderKeys.Sha1] = Header[HeaderKeys.Crc32] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Header[HeaderKeys.Crc32] != value || Header[HeaderKeys.Sha1] != string.Empty || Header[HeaderKeys.Md5] != string.Empty)
|
||||||
|
{
|
||||||
|
Changes = true;
|
||||||
|
Header[HeaderKeys.Crc32] = value;
|
||||||
|
Header[HeaderKeys.Sha1] = Header[HeaderKeys.Md5] = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue