hash +linux +x86_64

hash provides a generic interface for use with hashing functions.

Submodules

Index

Types

type hash;

Functions

fn bsz(*hash) size;
fn close(*hash) void;
fn reset(*hash) void;
fn sum(*hash, []u8) void;
fn sz(*hash) size;
fn write(*hash, 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: *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.