types

package
v0.0.0-...-9a64e19 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Bcrypt        EncoderType = "bcrypt" // use bcrypt hash
	Scrypt        EncoderType = "scrypt" // use scrypt hash
	Pbkdf2        EncoderType = "pbkdf2" // use pbkdf2 hash
	Argon2        EncoderType = "argon2" // use argon2 hash
	Hkdf          EncoderType = "hkdf"   // use hkdf hash
	SaltLen       int         = 16       // default size of salt value
	DefaultKeyLen             = 32
)

Variables

View Source
var DefaultHashFunc = sha256.New

Functions

func GenerateRandomSalt

func GenerateRandomSalt(len int) ([]byte, error)

GenerateRandomSalt generates random salt.

Types

type Encoder

type Encoder interface {
	// Encode returns the hash value of the given data
	Encode(src string) (string, error)
	// Verify compares a encoded data with its possible plaintext equivalent
	Verify(hash string, rawData string) (bool, error)
	// GetSalt Returns the salt if exists, otherwise nil
	GetSalt() ([]byte, error)
}

type EncoderType

type EncoderType string

type Option

type Option interface {
	Apply(Encoder)
}

An Option configures a Encoder

type OptionFunc

type OptionFunc func(e Encoder)

OptionFunc wraps a func so it satisfies the Option interface.

func (OptionFunc) Apply

func (f OptionFunc) Apply(e Encoder)

Apply config options for instance

Jump to

Keyboard shortcuts

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