mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 10:56:28 +02:00
22 lines
531 B
Go
22 lines
531 B
Go
// Package hashutil provides NON-CRYPTOGRAPHIC utility functions for hashing
|
|
package hashutil
|
|
|
|
import (
|
|
"github.com/cespare/xxhash/v2"
|
|
"github.com/mitchellh/hashstructure"
|
|
)
|
|
|
|
// 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)
|
|
if err != nil {
|
|
hash = 0
|
|
}
|
|
return hash
|
|
}
|