hashing

package
v0.0.0-...-a942fbd Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Argon2HashID represents the hash ID set in the (pseudo) modular crypt format used to store the hashed password and params in a single string.
	Argon2HashID = "argon2id"
)

Variables

View Source
var (
	// ErrInvalidArgon2Hash indicates the argon2id hash was malformed and could not be decoded.
	ErrInvalidArgon2Hash = errors.New("invalid argon2id hash")
	// ErrIncompatibleArgon2Version indicates the argon2id hash provided was generated with a different, incompatible argon2 version.
	ErrIncompatibleArgon2Version = errors.New("incompatible argon2 version")
)
View Source
var (
	// DefaultArgon2Params represents Argon2ID parameter recommendations in accordance with:
	// https://pkg.go.dev/golang.org/x/crypto@v0.0.0-20200420201142-3c4aac89819a/argon2?tab=doc#IDKey @ 2020-04-22T11:23:38Z
	DefaultArgon2Params = &Argon2Params{
		Time:       1,
		Memory:     64 * 1024,
		Threads:    4,
		KeyLength:  32,
		SaltLength: 16,
	}
)

Functions

func ComparePasswordAndHash

func ComparePasswordAndHash(password string, hash string) (matches bool, err error)

func HashPassword

func HashPassword(password string, params *Argon2Params) (hash string, err error)

Types

type Argon2Params

type Argon2Params struct {
	Time       uint32
	Memory     uint32
	Threads    uint8
	KeyLength  uint32
	SaltLength uint32
}

func DefaultArgon2ParamsFromEnv

func DefaultArgon2ParamsFromEnv() *Argon2Params

Jump to

Keyboard shortcuts

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