hkdf

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithHasFunc

func WithHasFunc(f func() hash.Hash) types.Option

WithHasFunc configure the ken hash func for Encoder, default value is sha256.New

func WithHashLen

func WithHashLen(len int) types.Option

WithHashLen configure the hash length for Encoder, default value is 32

func WithInfo

func WithInfo(info string) types.Option

WithInfo configure the info value for Encoder, default value is ""

func WithSalt

func WithSalt(salt []byte) types.Option

WithSalt configure the salt value for Encoder, default automatically generate random strings

func WithSaltLen

func WithSaltLen(len int) types.Option

WithSaltLen configure the salt length for Encoder, default value is 16

Types

type Encoder

type Encoder struct {
	SaltLen int // bytes to use as salt (octets)

	HashFunc func() hash.Hash
	Info     string
	HashLen  int // The length of the generated hash
	// contains filtered or unexported fields
}

func (*Encoder) Encode

func (e *Encoder) Encode(src string) (string, error)

Encode returns the hash value of the given data

func (*Encoder) GetSalt

func (e *Encoder) GetSalt() ([]byte, error)

GetSalt Returns the salt if present, otherwise nil

func (*Encoder) Hash added in v1.2.2

func (e *Encoder) Hash(src string) ([]byte, error)

Hash Generate and return a hash value in []byte format

func (*Encoder) Verify

func (e *Encoder) Verify(hash, rawData string) (bool, error)

Verify compares a encoded data with its possible plaintext equivalent

Jump to

Keyboard shortcuts

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