Interface IChecksum
Common interface for all non-cryptographic checksum algorithms provided by the Scylla checksum subsystem.
Namespace: Scylla.Core.Util.Checksum
Assembly: ScyllaCore.dll
Syntax
public interface IChecksum
Remarks
Provides a unified API for checksum operations, allowing different algorithms to be used interchangeably through polymorphism. All implementations support incremental (streaming) updates, meaning data can be fed in any number of chunks and the final checksum value is equivalent to processing the entire concatenated input at once.
The typical usage pattern is:
- Create an instance of the desired algorithm (e.g. ChecksumCRC32).
- Call Update(byte[]) or Update(byte[], int, int) one or more times with input data.
- Read the final checksum from Value.
- Optionally call Reset() to reuse the instance for a new computation.
All Value reads are non-destructive: reading the value does not alter internal state, and further Update(byte[]) calls remain valid after reading. This allows intermediate checksums to be observed during streaming.
The following algorithm implementations are available:
- ChecksumAdler32 - fast, zlib-compatible, 32-bit.
- ChecksumCRC16 - compact 16-bit CRC for protocol use (CCITT polynomial).
- ChecksumCRC32 - standard 32-bit CRC (IEEE 802.3), widely used for file and data integrity.
- ChecksumFletcher32 - 32-bit Fletcher checksum, designed for embedded and network use.
- ChecksumXXHash32 - extremely fast 32-bit hash with excellent distribution.
- ChecksumXXHash64 - extremely fast 64-bit hash for large data and lower collision probability.
Security note: None of these checksum algorithms are cryptographically secure. They are designed for error detection and fast hashing, not for tamper resistance. For security-sensitive applications such as message authentication or digital signatures, use the cryptographic utilities in the Scylla Crypto module instead.
Properties
Value
Gets the current checksum value computed from all data supplied to Update(byte[]) or Update(byte[], int, int) since the last Reset() call (or construction).
Declaration
long Value { get; }
Property Value
| Type | Description |
|---|---|
| long | The current checksum expressed as a |
Remarks
Reading this property is non-destructive. Subsequent Update(byte[]) calls continue accumulating into the same state and the next Value read will reflect the full combined input.
Methods
Reset()
Resets the checksum to its algorithm-defined initial state, discarding all previously accumulated data.
Declaration
void Reset()
Remarks
After calling Reset, Value returns the same value it would
return on a freshly constructed instance. This allows an instance to be reused
for multiple independent checksum computations without allocating a new object.
Update(byte[])
Updates the checksum with all bytes in the specified array.
Declaration
void Update(byte[] buffer)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | buffer | The byte array to process. If |
Remarks
This is a convenience overload equivalent to calling
Update(byte[], int, int) with offset = 0 and
count = buffer.Length.
Update(byte[], int, int)
Updates the checksum with a slice of the specified byte array.
Declaration
void Update(byte[] buffer, int offset, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | buffer | The byte array containing the input data. If |
| int | offset | The zero-based index within |
| int | count | The number of bytes to read starting at |
Remarks
Multiple calls to this method are cumulative: the checksum computed over a stream
of Update(byte[]) calls equals the checksum of the fully concatenated input.
Callers are responsible for ensuring that offset + count does not exceed
buffer.Length.