# Hashing and Checksums

> StringZilla for C#

```csharp
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
```

`using StringZilla;`

## Hasher

Incremental (streaming) StringZilla hash. Dispose to free the native state.

```csharp
class Hasher
```

## Hasher

Allocates and initializes the native hash state with the given _seed_ .

```csharp
Hasher(ulong seed = 0);
```

## *Update

Feeds _data_  into the hash.

```csharp
void Update(ReadOnlySpan<byte> data);
```

Throws ObjectDisposedException after disposal.

## Digest

Finalize without mutating state (may be called repeatedly).

```csharp
ulong Digest();
```

## *Dispose

Frees the native hash state; calling it again does nothing.

```csharp
void Dispose();
```

## Sha256

Incremental SHA-256.

```csharp
class Sha256
```

Dispose to free the native state.

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

## Sha256

```csharp
Sha256();
```

## Digest

Writes the 32-byte digest into _destination_  (must be ≥ 32 bytes; non-mutating, may be called repeatedly).

```csharp
void Digest(Span<byte> destination);
```

```csharp
byte[] Digest();
```

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

Allocation-free.

## HashData

One-shot SHA-256 of _data_  → 32-byte digest.

```csharp
byte[] HashData(ReadOnlySpan<byte> data);
```

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

