hash+x86_64 +linux

hash provides a generic interface for use with hashing functions.

Submodules

Index

Types

type hash = struct {
	// A stream which only supports writes and never returns errors.
	stream: io::stream,
	// Returns the current hash.
	sum: *fn(hash: *hash, buf: []u8) void,
	// Resets the hash function to its initial state.
	reset: nullable *fn(hash: *hash) void,
	// Size of the hash in bytes.
	sz: size,
	// Internal block size of the hash. Writing data to the hash
	// function in chunks of this size will not require padding to
	// obtain the final hash.
	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[link]

type hash = struct {
	// A stream which only supports writes and never returns errors.
	stream: io::stream,
	// Returns the current hash.
	sum: *fn(hash: *hash, buf: []u8) void,
	// Resets the hash function to its initial state.
	reset: nullable *fn(hash: *hash) void,
	// Size of the hash in bytes.
	sz: size,
	// Internal block size of the hash. Writing data to the hash
	// function in chunks of this size will not require padding to
	// obtain the final hash.
	bsz: size,
};

The general purpose interface for a hashing function.

Functions

fn bsz[link]

fn bsz(h: *hash) size;

Returns the block size of the hash.

fn close[link]

fn close(h: *hash) void;

Closes a hash, freeing its resources and discarding the checksum.

fn reset[link]

fn reset(h: *hash) void;

Resets the hash function to its initial state.

fn sum[link]

fn sum(h: *hash, buf: []u8) void;

Populates the user-provided buffer with the current sum.

fn sz[link]

fn sz(h: *hash) size;

Returns the size of the hash in bytes. This is consistent regardless of the hash state.

fn write[link]

fn write(h: *hash, buf: const []u8) size;

Writes an input to the hash function.