hash

package
v0.0.0-...-1d97044 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

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

func NewHash

func NewHash(version string) *Hash

func (*Hash) Dump

func (h *Hash) Dump(c interface{}) []byte

Dump takes a data structure and returns its byte representation. This can be useful if you need to use your own hashing function or formatter.

func (*Hash) Hash64

func (h *Hash) Hash64(v interface{}) (uint64, *errorAVA.Error)

func (*Hash) HashMD5

func (h *Hash) HashMD5(c interface{}) string

HashMD5 takes a data structure and returns a hash string of that data structure at the version asked. This function uses md5 hashing function and default formatter. See also Dump() function.

func (*Hash) HashSHA256

func (h *Hash) HashSHA256(c interface{}) []byte

HashSHA256 returns the sha 256 hash of the configurationServiceI in a standard base64 encoded string

func (*Hash) Md5

func (h *Hash) Md5(c interface{}) []byte

Md5 takes a data structure and returns its md5 hash. This is a shorthand for md5.Sum(Dump(c, version)).

func (*Hash) Sha1

func (h *Hash) Sha1(c interface{}) []byte

Sha1 takes a data structure and returns its sha1 hash. This is a shorthand for sha1.Sum(Dump(c, version)).

func (*Hash) Version

func (h *Hash) Version() int

version returns the version of the supplied hash as an integer or -1 on failure

type HashI

type HashI interface {
	Version() int
	Hash64(v interface{}) (uint64, *errorAVA.Error)
	HashMD5(c interface{}) string
	HashSHA256(c interface{}) []byte
	Md5(c interface{}) []byte
	Sha1(c interface{}) []byte
	Dump(c interface{}) []byte
}

type HashOptions

type HashOptions struct {
	// Hasher is the hash function to use. If this isn't set, it will default to FNV.
	Hasher _hash.Hash64

	// TagName is the struct tag to look at when hashing the structure.
	// By default this is "hash".
	TagName string

	// ZeroNil is flag determining if nil pointer should be treated equal to a zero value of pointed type. By default this is false.
	ZeroNil bool
}

HashOptions are options that are available for hashing.

type Includable

type Includable interface {
	HashInclude(field string, v interface{}) (bool, *errorAVA.Error)
}

Includable is an interface that can optionally be implemented by a struct. It will be called for each field in the struct to check whether it should be included in the hash.

type IncludableMap

type IncludableMap interface {
	HashIncludeMap(field string, k, v interface{}) (bool, *errorAVA.Error)
}

IncludableMap is an interface that can optionally be implemented by a struct. It will be called when a map-type field is found to ask the struct if the map item should be included in the hash.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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