Skip to content

hash #

Description

hash provides a way to hash binary data, i.e. produce a shorter value, that is highly content dependent, so even slightly different content will produce widely different hashes.

Hash functions are useful for implementing maps, caches etc.

fn sum64 #

fn sum64(key []u8, seed u64) u64

sum64 returns a hash given a byte array key and a seed.

fn sum64_string #

fn sum64_string(key string, seed u64) u64

sum64_string returns a hash given a V string key and a seed.

fn wyhash64_c #

fn wyhash64_c(a u64, b u64) u64

wyhash64_c returns a hash given two u64 values a and b.

fn wyhash_c #

fn wyhash_c(key &u8, len u64, seed u64) u64

wyhash_c returns a hash given a byte string key, its len, and a seed.

fn wymum #

fn wymum(a u64, b u64) u64

wymum returns a hash by performing multiply and mix on a and b.

interface Hash #

interface Hash {
mut:
	// Sum appends the current hash to b and returns the resulting array.
	// It does not change the underlying hash state.
	sum(b []u8) []u8
	size() int
	block_size() int
	free()
	reset()
	write(p []u8) !int
}