Get rid of unnecessary CRC32Checksum.cs
haven't checked for correctness or regressions
This commit is contained in:
parent
d979a09f5a
commit
558adfa325
|
@ -1,33 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
using BizHawk.Common.BufferExtensions;
|
|
||||||
|
|
||||||
namespace BizHawk.Common
|
|
||||||
{
|
|
||||||
/// <summary>uses <see cref="CRC32">custom implementation</see> of CRC-32 (i.e. POSIX cksum)</summary>
|
|
||||||
/// <seealso cref="MD5Checksum"/>
|
|
||||||
/// <seealso cref="SHA1Checksum"/>
|
|
||||||
/// <seealso cref="SHA256Checksum"/>
|
|
||||||
public static class CRC32Checksum
|
|
||||||
{
|
|
||||||
/// <remarks>in bits</remarks>
|
|
||||||
internal const int EXPECTED_LENGTH = 32;
|
|
||||||
|
|
||||||
internal const string PREFIX = "CRC32";
|
|
||||||
|
|
||||||
public static byte[] BytesAsDigest(uint digest)
|
|
||||||
{
|
|
||||||
var a = BitConverter.GetBytes(digest);
|
|
||||||
return new[] { a[3], a[2], a[1], a[0] };
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] Compute(ReadOnlySpan<byte> data)
|
|
||||||
=> BytesAsDigest(CRC32.Calculate(data));
|
|
||||||
|
|
||||||
public static string ComputeDigestHex(ReadOnlySpan<byte> data)
|
|
||||||
=> Compute(data).BytesToHexString();
|
|
||||||
|
|
||||||
public static string ComputePrefixedHex(ReadOnlySpan<byte> data)
|
|
||||||
=> $"{PREFIX}:{ComputeDigestHex(data)}";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@ using BizHawk.Common.BufferExtensions;
|
||||||
namespace BizHawk.Common
|
namespace BizHawk.Common
|
||||||
{
|
{
|
||||||
/// <summary>uses <see cref="MD5"/> implementation from BCL</summary>
|
/// <summary>uses <see cref="MD5"/> implementation from BCL</summary>
|
||||||
/// <seealso cref="CRC32Checksum"/>
|
|
||||||
/// <seealso cref="SHA1Checksum"/>
|
/// <seealso cref="SHA1Checksum"/>
|
||||||
/// <seealso cref="SHA256Checksum"/>
|
/// <seealso cref="SHA256Checksum"/>
|
||||||
public static class MD5Checksum
|
public static class MD5Checksum
|
||||||
|
|
|
@ -7,7 +7,6 @@ using BizHawk.Common.BufferExtensions;
|
||||||
namespace BizHawk.Common
|
namespace BizHawk.Common
|
||||||
{
|
{
|
||||||
/// <summary>uses <see cref="SHA1"/> implementation from BCL</summary>
|
/// <summary>uses <see cref="SHA1"/> implementation from BCL</summary>
|
||||||
/// <seealso cref="CRC32Checksum"/>
|
|
||||||
/// <seealso cref="MD5Checksum"/>
|
/// <seealso cref="MD5Checksum"/>
|
||||||
/// <seealso cref="SHA256Checksum"/>
|
/// <seealso cref="SHA256Checksum"/>
|
||||||
public static class SHA1Checksum
|
public static class SHA1Checksum
|
||||||
|
|
|
@ -7,7 +7,6 @@ using BizHawk.Common.BufferExtensions;
|
||||||
namespace BizHawk.Common
|
namespace BizHawk.Common
|
||||||
{
|
{
|
||||||
/// <summary>uses <see cref="SHA256"/> implementation from BCL</summary>
|
/// <summary>uses <see cref="SHA256"/> implementation from BCL</summary>
|
||||||
/// <seealso cref="CRC32Checksum"/>
|
|
||||||
/// <seealso cref="MD5Checksum"/>
|
/// <seealso cref="MD5Checksum"/>
|
||||||
/// <seealso cref="SHA1Checksum"/>
|
/// <seealso cref="SHA1Checksum"/>
|
||||||
public static class SHA256Checksum
|
public static class SHA256Checksum
|
||||||
|
|
|
@ -190,7 +190,7 @@ namespace BizHawk.Emulation.Common
|
||||||
{
|
{
|
||||||
acquire.WaitOne();
|
acquire.WaitOne();
|
||||||
|
|
||||||
var hashCRC32 = CRC32Checksum.ComputeDigestHex(romData);
|
var hashCRC32 = CRC32.Calculate(romData).ToString("X8");
|
||||||
if (DB.TryGetValue(hashCRC32, out var cgi))
|
if (DB.TryGetValue(hashCRC32, out var cgi))
|
||||||
{
|
{
|
||||||
return new GameInfo(cgi);
|
return new GameInfo(cgi);
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
crc.Add(buffer2352);
|
crc.Add(buffer2352);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CRC32Checksum.BytesAsDigest(crc.Result).BytesToHexString();
|
return crc.Result.ToString("X8");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -102,4 +102,4 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
return "no data track found";
|
return "no data track found";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue