C# · Hashing and Checksums

Hashing and Checksums

using StringZilla; 6.0.0-rc.1 · 91a27bdd

ulong digest = Sz.Hash(data, seed: 42);

using Hasher hasher = new(seed: 42); // streaming
hasher.Update(firstChunk);
hasher.Update(secondChunk);
ulong streamed = hasher.Digest();

byte[] sha = Sha256.HashData(data); // cf. System.Security.Cryptography.SHA256

API

ClassHasherIncremental (streaming) StringZilla hash. Dispose to free the native state.4
StringZilla.cs:1312 ↗
class Hasher
HasherAllocates and initializes the native hash state with the given seed .
StringZilla.cs:1318 ↗
Hasher(ulong seed = 0);
*Update× 2Feeds data into the hash.
StringZilla.cs:1325 ↗
void Update(ReadOnlySpan<byte> data);

Throws ObjectDisposedException after disposal.

DigestFinalize without mutating state (may be called repeatedly).
StringZilla.cs:1333 ↗
ulong Digest();
*Dispose× 2Frees the native hash state; calling it again does nothing.
StringZilla.cs:1341 ↗
void Dispose();
ClassSha256Incremental SHA-256.3
StringZilla.cs:1396 ↗
class Sha256

Dispose to free the native state.

Equivalent to System.Security.Cryptography.IncrementalHash with SHA-256, SIMD-accelerated. One-shot: HashData.

Sha256
StringZilla.cs:1399 ↗
Sha256();
DigestWrites the 32-byte digest into destination (must be ≥ 32 bytes; non-mutating, may be called repeatedly).
StringZilla.cs:1415 ↗
void Digest(Span<byte> destination);
byte[] Digest();

Finalize into a fresh 32-byte digest (non-mutating; may be called repeatedly).

Allocation-free.

HashDataOne-shot SHA-256 of data → 32-byte digest.
StringZilla.cs:1432 ↗
byte[] HashData(ReadOnlySpan<byte> data);

Equivalent to System.Security.Cryptography.SHA256.HashData(System.ReadOnlySpan<byte>).