murmur3

package
v0.0.0-...-86725a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

This package implements the 32 bit version of the MurmurHash3 hash code. With the exception of the interface check, this version was developed independtly. However, the "spaolacci" implementation with it's bmixer interface is da bomb, although this version is slightly faster.

https://en.wikipedia.org/wiki/MurmurHash https://github.com/spaolacci/murmur3

Index

Constants

View Source
const Size = 4

The size of an murmur3 32 bit hash in bytes.

Variables

This section is empty.

Functions

func New

func New(seed uint32) hash.Hash32

New returns a new hash.Hash32 interface that computes the a 32 bit murmur3 hash.

func Sum32

func Sum32(data []byte, seed uint32) uint32

Sum32 returns the 32 bit hash of data given the seed. This is code is what I started with before I added the hash.Hash and hash.Hash32 interfaces.

Types

type Digest

type Digest struct {
	// contains filtered or unexported fields
}

func (*Digest) BlockSize

func (d *Digest) BlockSize() int

Return the blocksize of the hash which in this case is 1 byte.

func (*Digest) Reset

func (d *Digest) Reset()

Reset the hash state.

func (*Digest) Size

func (d *Digest) Size() int

Return the size of the resulting hash.

func (*Digest) Sum

func (d *Digest) Sum(b []byte) []byte

Return the current hash as a byte slice.

func (*Digest) Sum32

func (d *Digest) Sum32() uint32

Return the current hash as a 32 bit unsigned type.

func (*Digest) Write

func (d *Digest) Write(p []byte) (nn int, err error)

Accept a byte stream p used for calculating the hash. For now this call is lazy and the actual hash calculations take place in Sum() and Sum32().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL