smhasher

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var N = 0
View Source
var Permutations = []Permutation{
	Permutation{8, []uint32{0, 1, 2, 3, 4, 5, 6, 7}},
	Permutation{8, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}},
	Permutation{20, []uint32{0, 1}},
	Permutation{20, []uint32{0, 1 << 31}},
	Permutation{6, []uint32{0, 1, 2, 3, 4, 5, 6, 7, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}},
}
View Source
var Tests = []Test{
	Test{TestSmhasherSanity, "TestSmhasherSanity"},
	Test{TestSmhasherSeed, "TestSmhasherSeed"},
	Test{TestSmhasherText, "TestSmhasherText"},
	Test{TestSmhasherWindowed, "TestSmhasherWindowed"},
	Test{TestSmhasherAvalanche, "TestSmhasherAvalanche"},
	Test{TestSmhasherPermutation, "TestSmhasherPermutation"},
	Test{TestSmhasherSparse, "TestSmhasherSparse"},
	Test{TestSmhasherCyclic, "TestSmhasherCyclic"},
	Test{TestSmhasherTwoNonzero, "TestSmhasherSmallKeys"},
	Test{TestSmhasherSmallKeys, "TestSmhasherZeros"},
	Test{TestSmhasherAppendedZeros, "TestSmhasherAppendedZeros"},
}

Functions

func BenchmarkHash1024

func BenchmarkHash1024()

func BenchmarkHash16

func BenchmarkHash16()

func BenchmarkHash5

func BenchmarkHash5()

func BenchmarkHash64

func BenchmarkHash64()

func BenchmarkHash65536

func BenchmarkHash65536()

func BytesHash

func BytesHash(b []byte, aseed uintptr) uintptr

func HaveGoodHash

func HaveGoodHash() bool

stubs for now

func Int32Hash

func Int32Hash(i uint32, aseed uintptr) uintptr

func Int64Hash

func Int64Hash(i uint64, aseed uintptr) uintptr

func RunSMhasher

func RunSMhasher(hashf string, v bool)

func SetBytes

func SetBytes(amt int64)

func Short

func Short() bool

func StringHash

func StringHash(s string, aseed uintptr) uintptr

func TestSmhasherAppendedZeros

func TestSmhasherAppendedZeros(t *TState) bool

a string plus adding zeros must make distinct hashes

func TestSmhasherAvalanche

func TestSmhasherAvalanche(t *TState) bool

Flipping a single bit of a key should flip each output bit with 50% probability.

func TestSmhasherCyclic

func TestSmhasherCyclic(t *TState) (ret bool)

Test strings with repeats, like "abcdabcdabcdabcd..."

func TestSmhasherPermutation

func TestSmhasherPermutation(t *TState) bool

Test all possible combinations of n blocks from the set s. "permutation" is a bad name here, but it is what Smhasher uses.

func TestSmhasherSanity

func TestSmhasherSanity(t *TState) (ret bool)

Sanity checks. hash should not depend on values outside key. hash should not depend on alignment.

func TestSmhasherSeed

func TestSmhasherSeed(t *TState) bool

Make sure different seed values generate different hashes.

func TestSmhasherSmallKeys

func TestSmhasherSmallKeys(t *TState) bool

All 0-3 byte strings have distinct hashes.

func TestSmhasherSparse

func TestSmhasherSparse(t *TState) (ret bool)

Test strings with only a few bits set

func TestSmhasherText

func TestSmhasherText(t *TState) bool

All keys of the form prefix + [A-Za-z0-9]*N + suffix.

func TestSmhasherTwoNonzero

func TestSmhasherTwoNonzero(t *TState) bool

Strings with up to two nonzero bytes all have distinct hashes.

func TestSmhasherWindowed

func TestSmhasherWindowed(t *TState) bool

All bit rotations of a set of distinct keys

func TestSmhasherZeros

func TestSmhasherZeros(t *TState) bool

Different length strings of all zeros have distinct hashes.

Types

type BytesKey

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

type HashSet

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

type Int32Key

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

type Int64Key

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

type Key

type Key interface {
	// contains filtered or unexported methods
}

type Permutation

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

type TState

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

type Test

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

Jump to

Keyboard shortcuts

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