hash

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blake3sum16

func Blake3sum16(input []byte) string

Blake3sum16 might be slower because we allocate a new hasher every time, but it is more conenient for writing debug code. It returns a 16 byte hash as a hexidecimal string.

func CryptoRandInt64

func CryptoRandInt64() int64

CryptoRandInt64 uses crypto/rand to get an random int64

func HashOfDir

func HashOfDir(path string) string

HashOfDir returns the hash of the local file system directory dir

Types

type Blake3Hasher

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

Blake3Hasher is a thread/goroutine safe way to obtain a blake3 cryptographic hash of input []byte. Reference https://github.com/BLAKE3-team/BLAKE3 suggests it is 6x faster than BLAKE2B. The Go github.com/zeebo/blake3 version is AVX2 and SSE4.1 accelerated.

func NewBlake3Hasher

func NewBlake3Hasher() *Blake3Hasher

NewBlake3Hasher returns a new Blake3Hasher.

func (*Blake3Hasher) CryptoHash

func (w *Blake3Hasher) CryptoHash(input []byte, buffer []byte) (outputCryptohash []byte)

CryptoHash writes the blake3 cryptographic hash of input into buffer and returns it. Like the standard libary's hash.Hash interface's Sum() method, the buffer is re-used and overwritten to avoid allocation. The caller determines the byte length of the outputCryptohash by the size of the supplied buffer slice, and this will be exactly equal to the supplies bytes. In this way, shorter or longer hashes can be provided as needed.

Jump to

Keyboard shortcuts

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