Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EncodeToSHA256 = func(buf []byte) (string, error) { hash, err := crypto.HashSHA256(buf) if err != nil { return "", err } return hex.EncodeToString(hash), nil }
EncodeToSHA256 returns a sha256 hash of data as string.
Functions ¶
func NewHashEncoder ¶
func NewHashEncoder(name string, hashFn HashingFunction, encoder jsoniter.ValEncoder) jsoniter.ValEncoder
NewHashEncoder returns a string encoder that with encode string value using the supplied hashFn. The hash encoder will run before the other encoders, ensuring that struct fields are hashed first.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a ValEncoder strings that hashes string data with HashingFunction before encoding it to stream.
func (*Encoder) Encode ¶
Encode writes the value of ptr to stream.
func (*Encoder) IsEmpty ¶
IsEmpty returns true is ptr is empty, otherwise false.
type HashingFunction ¶
HashingFunction defines the prototype for the hash callback. Defaults to EncodeToSHA256.
func FunctionForName ¶
func FunctionForName(name tags.Hash) HashingFunction
FunctionForName returns the hash function for a given otherwise nil (passthrough).
Click to show internal directories.
Click to hide internal directories.