argon2

package
v0.0.0-...-baa204d Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHashTime       = 4
	DefaultHashMemory     = 64 * 1024
	DefaultHashThreads    = 4
	DefaultHashKeyLength  = 64
	DefaultHashSaltLength = 16
)

Variables

View Source
var (
	ErrInvalidEncodedHash = errors.New("hash is in an unrecognizable format")
	ErrAlgorithmMismatch  = errors.New("hash does not use argon2id")
	ErrVersionMismatch    = errors.New("hash's argon2id version differs from current")
	ErrEmptyPassword      = errors.New("password cannot be empty")
)
View Source
var (
	DefaultParameters = &Parameters{
		Time:       DefaultHashTime,
		Memory:     DefaultHashMemory,
		Threads:    DefaultHashThreads,
		KeyLength:  DefaultHashKeyLength,
		SaltLength: DefaultHashSaltLength,
	}
)

Functions

func CheckPassword

func CheckPassword(password string, encoded string) (match bool)

CheckPassword compares a string to a known encoded hash, using all the same parameters and salt as the known hash. In cases where you might expect a normal function to return an err, we'll just return false.

Types

type Parameters

type Parameters struct {
	Time       uint32 // Number of passes to run
	Memory     uint32 // Size of memory to use in KiB
	Threads    uint8  // Number of threads to use
	KeyLength  uint32 // Length of resulting hash
	SaltLength uint32 // Length of salt to generate
}

func (*Parameters) HashPassword

func (p *Parameters) HashPassword(password string) (encoded string, err error)

HashPassword returns an encoded string with all the necessary parameters encoded, separated by "$".

Jump to

Keyboard shortcuts

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