seahash

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: MIT Imports: 1 Imported by: 6

README

seahash

Build Status GoDoc

A Go port of the SeaHash algorithm.

Benchmarks

Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz running Linux 5.3.0

BenchmarkSeahash64-8           	55457641	        20.8 ns/op	       0 B/op	       0 allocs/op

BenchmarkFnvHash32-8           	40879219	        30.2 ns/op	       4 B/op	       1 allocs/op
BenchmarkFnvHash64-8           	34940972	        30.6 ns/op	       8 B/op	       1 allocs/op

BenchmarkFarmHashHash32-8      	61766998	        19.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkFarmHashHash64-8      	100000000	        11.6 ns/op	       0 B/op	       0 allocs/op

BenchmarkHuichenMurmur-8       	81137569	        13.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkReuseeMurmur-8        	21982393	        52.7 ns/op	       4 B/op	       1 allocs/op
BenchmarkZhangMurmur-8         	91060291	        14.1 ns/op	       0 B/op	       0 allocs/op

BenchmarkDgryskiSpooky32-8     	44230748	        27.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkDgryskiSpooky64-8     	48947028	        23.9 ns/op	       0 B/op	       0 allocs/op

BenchmarkDgryskiStatdx64-8     	100000000	        11.5 ns/op	       0 B/op	       0 allocs/op

BenchmarkHashlandSpooky32-8   	40680852	        29.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkHashlandSpooky64-8   	43915500	        28.0 ns/op	       0 B/op	       0 allocs/op

BenchmarkCreachadairCity32-8   	39462910	        28.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkCreachadairCity64-8   	80871393	        15.4 ns/op	       0 B/op	       0 allocs/op

Documentation

Overview

Package seahash implements SeaHash, a non-cryptographic hash function created by http://ticki.github.io.

See https://ticki.github.io/blog/seahash-explained.

Index

Examples

Constants

View Source
const BlockSize = 8

BlockSize of SeaHash in bytes.

View Source
const Size = 8

Size of a SeaHash checksum in bytes.

Variables

This section is empty.

Functions

func Sum

func Sum(b []byte) []byte

Sum is a convenience method that returns the checksum of the byte slice

Example
// hash some bytes
hash := Sum([]byte("to be or not to be"))
fmt.Printf("%x", hash)
Output:

75e54a6f823a991b

func Sum64 added in v1.1.0

func Sum64(b []byte) uint64

Sum64 is a convenience method that returns uint64 checksum of the byte slice

Example
// hash some bytes
fmt.Printf("%x", Sum64([]byte("to be or not to be")))
Output:

1b993a826f4ae575

Types

type Hasher added in v1.2.0

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

func New

func New() *Hasher

New creates a new SeaHash hash.Hash64

Example
// hash some bytes
h := New()
h.Write([]byte("to be or not to be"))
hash := h.Sum64()
fmt.Printf("%x", hash)
Output:

1b993a826f4ae575

func (*Hasher) BlockSize added in v1.2.0

func (h *Hasher) BlockSize() int

BlockSize returns BlockSize constant to satisfy hash.Hash interface

func (*Hasher) Reset added in v1.2.0

func (h *Hasher) Reset()

func (*Hasher) Size added in v1.2.0

func (h *Hasher) Size() int

Size returns Size constant to satisfy hash.Hash interface

func (*Hasher) Sum added in v1.2.0

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

func (*Hasher) Sum64 added in v1.2.0

func (h *Hasher) Sum64() uint64

func (*Hasher) Write added in v1.2.0

func (h *Hasher) Write(b []byte) (nn int, err error)

Jump to

Keyboard shortcuts

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