hash
hash: cryptographic and non-cryptographic hashing algorithms
hash provides a generic interface for use with hashing functions.
Submodules
- adler32:
Adler-32 checksum algorithm
- crc16:
CRC-16 (Cyclic Redundancy Check) support
- crc32:
CRC-32 (Cyclic Redundancy Check) support
- crc64:
CRC-64 (Cyclic Redundancy Check) support
- fnv:
Fowler–Noll–Vo (FNV) support, for trusted hash map keys
- siphash:
SipHash keyed hash function, for untrusted hash map keys
Index
Types
type hash = struct {
stream: io::stream,
sum: *fn(hash: *hash, buf: []u8) void,
reset: nullable *fn(hash: *hash) void,
sz: size,
bsz: size,
};
Functions
fn bsz(h: *hash) size;
fn close(h: *hash) void;
fn reset(h: *hash) void;
fn sum(h: *hash, buf: []u8) void;
fn sz(h: *hash) size;
fn write(h: *hash, buf: const []u8) size;
Types
type hash
type hash = struct {
stream: io::stream,
sum: *fn(hash: *hash, buf: []u8) void,
reset: nullable *fn(hash: *hash) void,
sz: size,
bsz: size,
};
The general purpose interface for a hashing function.
Functions
fn bsz
fn bsz(h: *hash) size;
Returns the block size of the hash.
fn close
fn close(h: *hash) void;
Closes a hash, freeing its resources and discarding the checksum.
fn reset
fn reset(h: *hash) void;
Resets the hash function to its initial state.
fn sum
fn sum(h: *hash, buf: []u8) void;
Populates the user-provided buffer with the current sum.
fn sz
fn sz(h: *hash) size;
Returns the size of the hash in bytes. This is consistent regardless of the hash state.
fn write
fn write(h: *hash, buf: const []u8) size;
Writes an input to the hash function.