hashing

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PassField             = "password"
	PassMinLength         = 8
	PassMaxLength         = 32
	EntropyMinForPassword = 70
	BCryptCost            = 13
)
View Source
const (
	SaltLength = 16
)

Variables

View Source
var (
	ErrInvalidHash         = errors.New("argon2id: hash is not in the correct format")
	ErrIncompatibleVariant = errors.New("argon2id: incompatible variant of argon2")
	ErrIncompatibleVersion = errors.New("argon2id: incompatible version of argon2")
	DefaultParams          = &Params{
		Memory:      memoryLimit,
		Iterations:  4,
		Parallelism: 4,
		SaltLength:  SaltLength,
		KeyLength:   32,
	}
)

Functions

func Argon2ID

func Argon2ID(password string) (hash string)

func Argon2IDComparePasswordAndHash

func Argon2IDComparePasswordAndHash(password, hash string) (match bool, err error)

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func HashPassword

func HashPassword(password string) (string, error)

func Validate

func Validate(password, passwordConfirm string) error

Types

type MismatchError

type MismatchError struct {
	// contains filtered or unexported fields
}

func (MismatchError) Error

func (m MismatchError) Error() string

type Params

type Params struct {
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
	SaltLength  uint32
	KeyLength   uint32
}

func CheckHash

func CheckHash(password, hash string) (match bool, params *Params, err error)

func DecodeHash

func DecodeHash(hash string) (params *Params, salt, key []byte, err error)

type ValidationError

type ValidationError struct {
	Message string
	Field   string
}

func (*ValidationError) Error

func (ve *ValidationError) Error() string

Jump to

Keyboard shortcuts

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