mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-12 06:18:19 +02:00
deps: update hashstructure v2 (#1632)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
3f7777f7e0
commit
652e8bb3d3
7 changed files with 51 additions and 43 deletions
|
@ -1,22 +1,29 @@
|
|||
// Package hashutil provides NON-CRYPTOGRAPHIC utility functions for hashing
|
||||
// Package hashutil provides NON-CRYPTOGRAPHIC utility functions for hashing.
|
||||
//
|
||||
// http://cyan4973.github.io/xxHash/
|
||||
package hashutil
|
||||
|
||||
import (
|
||||
"github.com/cespare/xxhash/v2"
|
||||
"github.com/mitchellh/hashstructure"
|
||||
"github.com/mitchellh/hashstructure/v2"
|
||||
)
|
||||
|
||||
// Hash returns the xxhash value of an arbitrary value or struct. Returns 0
|
||||
// on error. NOT SUITABLE FOR CRYTOGRAPHIC HASHING.
|
||||
//
|
||||
// http://cyan4973.github.io/xxHash/
|
||||
func Hash(v interface{}) uint64 {
|
||||
opts := &hashstructure.HashOptions{
|
||||
Hasher: xxhash.New(),
|
||||
}
|
||||
hash, err := hashstructure.Hash(v, opts)
|
||||
// MustHash returns the xxhash of an arbitrary value or struct. Returns 0
|
||||
// on error.
|
||||
// NOT SUITABLE FOR CRYTOGRAPHIC HASHING.
|
||||
func MustHash(v interface{}) uint64 {
|
||||
hash, err := Hash(v)
|
||||
if err != nil {
|
||||
hash = 0
|
||||
}
|
||||
return hash
|
||||
}
|
||||
|
||||
// Hash returns the xxhash of an arbitrary value or struct.
|
||||
// NOT SUITABLE FOR CRYTOGRAPHIC HASHING.
|
||||
func Hash(v interface{}) (uint64, error) {
|
||||
opts := &hashstructure.HashOptions{
|
||||
Hasher: xxhash.New(),
|
||||
}
|
||||
return hashstructure.Hash(v, hashstructure.FormatV2, opts)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue