ahash

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: BSD-2-Clause, ISC Imports: 18 Imported by: 0

Documentation

Overview

Package ahash provides support for hashing data with a selectable

hash function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashList

func HashList() []string

HashList returns a sorted list of all the hash algorithms supported by the package.

func InsecureHashList

func InsecureHashList() []string

InsecureHashList returns a sorted list of all the insecure hash algorithms supported by the package.

func SecureHashList

func SecureHashList() []string

SecureHashList returns a sorted list of all the secure (cryptographic) hash algorithms supported by the package.

func Sum

func Sum(algo string, data []byte) ([]byte, error)

Sum returns the digest (not the hex digest) of the data using the given algorithm.

func SumLimitedReader added in v1.6.0

func SumLimitedReader(algo string, r io.Reader, n int64) ([]byte, error)

SumLimitedReader reads n bytes of data from the io.reader and returns the digest (not the hex digest) from the specified algorithm.

func SumReader

func SumReader(algo string, r io.Reader) ([]byte, error)

SumReader reads all the data from the given io.Reader and returns the digest (not the hex digest) from the specified algorithm.

Types

type Hash

type Hash struct {
	hash.Hash
	// contains filtered or unexported fields
}

Hash represents a generic hash function that may or may not be secure. It satisfies the hash.Hash interface.

func New

func New(algo string) (*Hash, error)

New returns a new Hash for the specified algorithm.

func (*Hash) HashAlgo

func (h *Hash) HashAlgo() string

HashAlgo returns the name of the underlying hash algorithm.

func (*Hash) IsHash32

func (h *Hash) IsHash32() bool

IsHash32 returns true if the underlying hash is a 32-bit hash function.

func (*Hash) IsHash64

func (h *Hash) IsHash64() bool

IsHash64 returns true if the underlying hash is a 64-bit hash function.

func (*Hash) IsSecure

func (h *Hash) IsSecure() bool

IsSecure returns true if the Hash is a cryptographic hash.

func (*Hash) Sum32

func (h *Hash) Sum32() (uint32, bool)

Sum32 returns true if the underlying hash is a 32-bit hash; if is, the uint32 parameter will contain the hash.

func (*Hash) Sum64

func (h *Hash) Sum64() (uint64, bool)

Sum64 returns true if the underlying hash is a 64-bit hash; if is, the uint64 parameter will contain the hash.

Jump to

Keyboard shortcuts

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