mirror of
https://github.com/aaru-dps/Aaru.Checksums.git
synced 2025-12-16 19:24:29 +00:00
Add XML comments to public entities.
This commit is contained in:
@@ -45,8 +45,21 @@ namespace Aaru.Checksums
|
||||
static byte[] _eccBTable;
|
||||
static uint[] _edcTable;
|
||||
|
||||
/// <summary>
|
||||
/// Checks the EDC and ECC of a CD sector
|
||||
/// </summary>
|
||||
/// <param name="buffer">CD sector</param>
|
||||
/// <returns><c>true</c> if all checks were correct, <c>false</c> if any of them weren't, and <c>null</c> if none of them are present.</returns>
|
||||
public static bool? CheckCdSector(byte[] buffer) => CheckCdSector(buffer, out _, out _, out _);
|
||||
|
||||
/// <summary>
|
||||
/// Checks the EDC and ECC of a CD sector
|
||||
/// </summary>
|
||||
/// <param name="buffer">CD sector</param>
|
||||
/// <param name="correctEccP"><c>true</c> if ECC P is correct, <c>false</c> if it isn't, and <c>null</c> if there is no ECC P in sector.</param>
|
||||
/// <param name="correctEccQ"><c>true</c> if ECC Q is correct, <c>false</c> if it isn't, and <c>null</c> if there is no ECC Q in sector.</param>
|
||||
/// <param name="correctEdc"><c>true</c> if EDC is correct, <c>false</c> if it isn't, and <c>null</c> if there is no EDC in sector.</param>
|
||||
/// <returns><c>true</c> if all checks were correct, <c>false</c> if any of them weren't, and <c>null</c> if none of them are present.</returns>
|
||||
public static bool? CheckCdSector(byte[] buffer, out bool? correctEccP, out bool? correctEccQ,
|
||||
out bool? correctEdc)
|
||||
{
|
||||
|
||||
@@ -32,9 +32,14 @@
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the CRC16 algorithm with CCITT polynomial and seed
|
||||
/// </summary>
|
||||
public sealed class CRC16CCITTContext : Crc16Context
|
||||
{
|
||||
/// <summary>CCITT CRC16 polynomial</summary>
|
||||
public const ushort CRC16_CCITT_POLY = 0x8408;
|
||||
/// <summary>CCITT CRC16 seed</summary>
|
||||
public const ushort CRC16_CCITT_SEED = 0x0000;
|
||||
static readonly ushort[] _ccittCrc16Table =
|
||||
{
|
||||
@@ -60,6 +65,10 @@ namespace Aaru.Checksums
|
||||
0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of the CRC16 with CCITT polynomial and seed.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public CRC16CCITTContext() : base(CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true) {}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
@@ -89,6 +98,10 @@ namespace Aaru.Checksums
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the CCITT CRC16 of the specified buffer with the specified parameters
|
||||
/// </summary>
|
||||
/// <param name="buffer">Buffer</param>
|
||||
public static ushort Calculate(byte[] buffer) =>
|
||||
Calculate(buffer, CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true);
|
||||
}
|
||||
|
||||
@@ -214,6 +214,15 @@ namespace Aaru.Checksums
|
||||
return crc16Output.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the CRC16 of the specified buffer with the specified parameters
|
||||
/// </summary>
|
||||
/// <param name="buffer">Buffer</param>
|
||||
/// <param name="polynomial">Polynomial</param>
|
||||
/// <param name="seed">Seed</param>
|
||||
/// <param name="table">Pre-generated lookup table</param>
|
||||
/// <param name="inverse">Inverse CRC</param>
|
||||
/// <returns>CRC16</returns>
|
||||
public static ushort Calculate(byte[] buffer, ushort polynomial, ushort seed, ushort[] table, bool inverse)
|
||||
{
|
||||
ushort[] localTable = table ?? GenerateTable(polynomial, inverse);
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the CRC16 algorithm with IBM polynomial and seed
|
||||
/// </summary>
|
||||
public sealed class CRC16IBMContext : Crc16Context
|
||||
{
|
||||
const ushort CRC16_IBM_POLY = 0xA001;
|
||||
@@ -61,6 +64,10 @@ namespace Aaru.Checksums
|
||||
0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of the CRC16 with IBM polynomial and seed.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public CRC16IBMContext() : base(CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false) {}
|
||||
|
||||
/// <summary>Gets the hash of a file</summary>
|
||||
@@ -90,6 +97,10 @@ namespace Aaru.Checksums
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the IBM CRC16 of the specified buffer with the specified parameters
|
||||
/// </summary>
|
||||
/// <param name="buffer">Buffer</param>
|
||||
public static ushort Calculate(byte[] buffer) =>
|
||||
Calculate(buffer, CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,13 @@ namespace Aaru.Checksums
|
||||
/// <summary>Implements a CRC64 algorithm</summary>
|
||||
public sealed class Crc64Context : IChecksum
|
||||
{
|
||||
/// <summary>
|
||||
/// ECMA CRC64 polynomial
|
||||
/// </summary>
|
||||
public const ulong CRC64_ECMA_POLY = 0xC96C5795D7870F42;
|
||||
/// <summary>
|
||||
/// ECMA CRC64 seed
|
||||
/// </summary>
|
||||
public const ulong CRC64_ECMA_SEED = 0xFFFFFFFFFFFFFFFF;
|
||||
|
||||
readonly ulong _finalSeed;
|
||||
|
||||
11
Register.cs
11
Register.cs
@@ -44,29 +44,40 @@ using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.Checksums
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public sealed class Register : IPluginRegister
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllChecksumPlugins() => Assembly.
|
||||
GetExecutingAssembly().GetTypes().
|
||||
Where(t => t.GetInterfaces().Contains(typeof(IChecksum))).
|
||||
Where(t => t.IsClass).ToList();
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllFilesystemPlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllFilterPlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllFloppyImagePlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllMediaImagePlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllPartitionPlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllReadOnlyFilesystemPlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllWritableFloppyImagePlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllWritableImagePlugins() => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<Type> GetAllArchivePlugins() => null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user