pbkdf2

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: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultIterations = 10000
)

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 WithIterations

func WithIterations(iter int) types.Option

WithIterations configure the iterations for Encoder, default value is 10000

func WithKeyLen

func WithKeyLen(len int) types.Option

WithKeyLen configure the key length for Encoder, default value is 32

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
	Iterations int
	KeyLen     int
	HashFunc   func() hash.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