mk.helpers
Search Results for

    Show / Hide Table of Contents

    Class Crc32Hash

    Implements a 32-bit CRC hash algorithm compatible with Zip etc.

    Inheritance
    object
    HashAlgorithm
    Crc32Hash
    Implements
    ICryptoTransform
    IDisposable
    Inherited Members
    HashAlgorithm.Clear()
    HashAlgorithm.ComputeHash(byte[])
    HashAlgorithm.ComputeHash(byte[], int, int)
    HashAlgorithm.ComputeHash(Stream)
    HashAlgorithm.Create()
    HashAlgorithm.Create(string)
    HashAlgorithm.Dispose()
    HashAlgorithm.TransformBlock(byte[], int, int, byte[], int)
    HashAlgorithm.TransformFinalBlock(byte[], int, int)
    HashAlgorithm.TryComputeHash(ReadOnlySpan<byte>, Span<byte>, out int)
    HashAlgorithm.CanReuseTransform
    HashAlgorithm.CanTransformMultipleBlocks
    HashAlgorithm.Hash
    HashAlgorithm.InputBlockSize
    HashAlgorithm.OutputBlockSize
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: mk.helpers
    Assembly: mk.helpers.dll
    Syntax
    public sealed class Crc32Hash : HashAlgorithm, ICryptoTransform, IDisposable
    Remarks

    Crc32 should only be used for backward compatibility with older file formats and algorithms. It is not secure enough for new applications. If you need to call multiple times for the same data either use the HashAlgorithm interface or remember that the result of one Compute call needs to be ~ (XOR) before being passed in as the seed for the next Compute call.

    Constructors

    Crc32Hash()

    Initializes a new instance of the Crc32Hash class using the default polynomial and seed values.

    Declaration
    public Crc32Hash()

    Crc32Hash(uint, uint)

    Initializes a new instance of the Crc32Hash class using the specified polynomial and seed values.

    Declaration
    public Crc32Hash(uint polynomial, uint seed)
    Parameters
    Type Name Description
    uint polynomial

    The polynomial value to use for CRC32 calculation.

    uint seed

    The seed value to use for CRC32 calculation.

    Fields

    DefaultPolynomial

    Default polynomial value for CRC32 calculation.

    Declaration
    public const uint DefaultPolynomial = 3988292384
    Field Value
    Type Description
    uint

    DefaultSeed

    Default seed value for CRC32 calculation.

    Declaration
    public const uint DefaultSeed = 4294967295
    Field Value
    Type Description
    uint

    Properties

    HashSize

    Gets the size, in bits, of the computed hash code.

    Declaration
    public override int HashSize { get; }
    Property Value
    Type Description
    int

    The size, in bits, of the computed hash code.

    Overrides
    HashAlgorithm.HashSize

    Methods

    Compute(byte[])

    Computes the CRC32 hash value for the specified buffer using the default seed value.

    Declaration
    public static uint Compute(byte[] buffer)
    Parameters
    Type Name Description
    byte[] buffer

    The input buffer for which to compute the hash value.

    Returns
    Type Description
    uint

    The computed CRC32 hash value.

    Compute(uint, byte[])

    Computes the CRC32 hash value for the specified buffer using the specified seed value.

    Declaration
    public static uint Compute(uint seed, byte[] buffer)
    Parameters
    Type Name Description
    uint seed

    The seed value to use for CRC32 calculation.

    byte[] buffer

    The input buffer for which to compute the hash value.

    Returns
    Type Description
    uint

    The computed CRC32 hash value.

    Compute(uint, uint, byte[])

    Computes the CRC32 hash value for the specified buffer using the specified polynomial and seed values.

    Declaration
    public static uint Compute(uint polynomial, uint seed, byte[] buffer)
    Parameters
    Type Name Description
    uint polynomial

    The polynomial value to use for CRC32 calculation.

    uint seed

    The seed value to use for CRC32 calculation.

    byte[] buffer

    The input buffer for which to compute the hash value.

    Returns
    Type Description
    uint

    The computed CRC32 hash value.

    HashCore(byte[], int, int)

    When overridden in a derived class, routes data written to the object into the hash algorithm for computing the hash.

    Declaration
    protected override void HashCore(byte[] array, int ibStart, int cbSize)
    Parameters
    Type Name Description
    byte[] array

    The input to compute the hash code for.

    int ibStart

    The offset into the byte array from which to begin using data.

    int cbSize

    The number of bytes in the byte array to use as data.

    Overrides
    HashAlgorithm.HashCore(byte[], int, int)

    HashFinal()

    When overridden in a derived class, finalizes the hash computation after the last data is processed by the cryptographic stream object.

    Declaration
    protected override byte[] HashFinal()
    Returns
    Type Description
    byte[]

    The computed hash code.

    Overrides
    HashAlgorithm.HashFinal()

    Initialize()

    Initializes an implementation of the HashAlgorithm class.

    Declaration
    public override void Initialize()
    Overrides
    HashAlgorithm.Initialize()

    Implements

    ICryptoTransform
    IDisposable

    Extension Methods

    ObjectExtensions.AsDictionary(object)
    ObjectExtensions.ToExpandoObject(object)
    ReflectionHelper.Changes(object, object)
    ReflectionHelper.CopyProperties(object, object, out List<EntityChange>)
    ReflectionHelper.CopyProperties(object, object, out List<EntityChange>, params string[])
    ReflectionHelper.CopyProperties(object, object, params string[])
    ReflectionHelper.CopyPropertiesFrom(object, object, out List<EntityChange>)
    ReflectionHelper.CopyPropertiesFrom(object, object, params string[])
    ObjectExtensions.IsDefault<T>(T)
    ObjectExtensions.IsIn<T>(T, params T[])
    ReflectionHelper.DeepClone<T>(T)
    ReflectionHelper.PublicPropertiesEqual<T>(T, T, params string[])
    EnumerableExtensions.IsAnyOf<T>(T, params T[])
    EnumerableExtensions.Yield<T>(T)
    In this article
    Back to top mk.helpers - MIT License