wyhash

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package wyhash implements https://github.com/wangyi-fudan/wyhash

Index

Constants

View Source
const (
	DefaultSeed = 0xa0761d6478bd642f // s0

)

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts a byte slice to a string.

This is a shallow copy, means that the returned string reuse the underlying array in byte slice, it's your responsibility to keep the input byte slice survive until you don't access the string anymore.

func Sum64

func Sum64(data []byte) uint64

func Sum64String

func Sum64String(data string) uint64

func Sum64StringWithSeed

func Sum64StringWithSeed(data string, seed uint64) uint64

func Sum64WithSeed

func Sum64WithSeed(data []byte, seed uint64) uint64

Types

type Digest

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

func New

func New(seed uint64) *Digest

New creates a new Digest that computes the 64-bit wyhash algorithm.

func NewDefault

func NewDefault() *Digest

func (*Digest) BlockSize

func (d *Digest) BlockSize() int

BlockSize always returns 64 bytes.

func (*Digest) InitSeed

func (d *Digest) InitSeed() uint64

func (*Digest) Reset

func (d *Digest) Reset()

Reset the digest, and the seed will be reset to initseed. The initseed is the seed when digest has been created.

func (*Digest) Seed

func (d *Digest) Seed() uint64

func (*Digest) SetInitSeed

func (d *Digest) SetInitSeed(seed uint64)

func (*Digest) SetSeed

func (d *Digest) SetSeed(seed uint64)

func (*Digest) Size

func (d *Digest) Size() int

Size always returns 8 bytes.

func (*Digest) Sum

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

Sum appends the current hash to b and returns the resulting slice.

func (*Digest) Sum64

func (d *Digest) Sum64() uint64

Sum64 returns the current hash.

func (*Digest) Write

func (d *Digest) Write(input []byte) (int, error)

Write (via the embedded io.Writer interface) adds more data to the running hash. It never returns an error.

Jump to

Keyboard shortcuts

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