Čítať v angličtine Upraviť

Zdieľať cez


Crc32 Class

Definition

Provides an implementation of the CRC-32 algorithm, as used in ITU-T V.42 and IEEE 802.3.

C#
public sealed class Crc32 : System.IO.Hashing.NonCryptographicHashAlgorithm
Inheritance

Remarks

This implementation emits the answer in the Little Endian byte order so that the CRC residue relationship (CRC(message concat CRC(message)) is a fixed value) holds. For CRC-32, this stable output is the byte sequence { 0x1C, 0xDF, 0x44, 0x21 }, the Little Endian representation of 0x2144DF1C.

There are multiple, incompatible, definitions of a 32-bit cyclic redundancy check (CRC) algorithm. When interoperating with another system, ensure that you are using the same definition. The definition used by this implementation is not compatible with the cyclic redundancy check described in ITU-T I.363.5.

Constructors

Crc32()

Initializes a new instance of the Crc32 class.

Properties

HashLengthInBytes

Gets the number of bytes produced from this hash algorithm.

(Inherited from NonCryptographicHashAlgorithm)

Methods

Append(Byte[])

Appends the contents of source to the data already processed for the current hash computation.

(Inherited from NonCryptographicHashAlgorithm)
Append(ReadOnlySpan<Byte>)

Appends the contents of source to the data already processed for the current hash computation.

Append(Stream)

Appends the contents of stream to the data already processed for the current hash computation.

(Inherited from NonCryptographicHashAlgorithm)
AppendAsync(Stream, CancellationToken)

Asychronously reads the contents of stream and appends them to the data already processed for the current hash computation.

(Inherited from NonCryptographicHashAlgorithm)
GetCurrentHash()

Gets the current computed hash value without modifying accumulated state.

(Inherited from NonCryptographicHashAlgorithm)
GetCurrentHash(Span<Byte>)

Writes the computed hash value to destination without modifying accumulated state.

(Inherited from NonCryptographicHashAlgorithm)
GetCurrentHashAsUInt32()

Gets the current computed hash value without modifying accumulated state.

GetCurrentHashCore(Span<Byte>)

When overridden in a derived class, writes the computed hash value to destination without modifying accumulated state.

(Inherited from NonCryptographicHashAlgorithm)
GetHashAndReset()

Gets the current computed hash value and clears the accumulated state.

(Inherited from NonCryptographicHashAlgorithm)
GetHashAndReset(Span<Byte>)

Writes the computed hash value to destination then clears the accumulated state.

(Inherited from NonCryptographicHashAlgorithm)
GetHashAndResetCore(Span<Byte>)

Writes the computed hash value to destination then clears the accumulated state.

(Inherited from NonCryptographicHashAlgorithm)
GetHashCode()
Obsolete.

This method is not supported and should not be called. Call GetCurrentHash() or GetHashAndReset() instead.

(Inherited from NonCryptographicHashAlgorithm)
Hash(Byte[])

Computes the CRC-32 hash of the provided data.

Hash(ReadOnlySpan<Byte>, Span<Byte>)

Computes the CRC-32 hash of the provided data into the provided destination.

Hash(ReadOnlySpan<Byte>)

Computes the CRC-32 hash of the provided data.

HashToUInt32(ReadOnlySpan<Byte>)

Computes the CRC-32 hash of the provided data.

Reset()

Resets the hash computation to the initial state.

TryGetCurrentHash(Span<Byte>, Int32)

Attempts to write the computed hash value to destination without modifying accumulated state.

(Inherited from NonCryptographicHashAlgorithm)
TryGetHashAndReset(Span<Byte>, Int32)

Attempts to write the computed hash value to destination. If successful, clears the accumulated state.

(Inherited from NonCryptographicHashAlgorithm)
TryHash(ReadOnlySpan<Byte>, Span<Byte>, Int32)

Attempts to compute the CRC-32 hash of the provided data into the provided destination.

Applies to

Produkt Verzie
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)