hash
hash provides a generic interface for use with hashing functions.
Submodules
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.