seahash

package
v0.0.0-...-4624acb Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0, MIT Imports: 1 Imported by: 1

Documentation

Overview

The file is copied from blainsmith.com/go/seahash@v1.2.1.

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

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

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

Hasher is an instance to calculate checksum.

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

func (h *Hasher) BlockSize() int

BlockSize returns BlockSize constant to satisfy hash.Hash interface

func (*Hasher) Reset

func (h *Hasher) Reset()

Reset resets the Hasher.

func (*Hasher) Size

func (h *Hasher) Size() int

Size returns Size constant to satisfy hash.Hash interface

func (*Hasher) Sum

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

Sum calculates the checksum bytes.

func (*Hasher) Sum64

func (h *Hasher) Sum64() uint64

Sum64 calculates the checksum.

func (*Hasher) Write

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

Write writes the given buffer into the Hasher.

Jump to

Keyboard shortcuts

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