argon2

package
v0.0.6-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash         = errors.New("argon2id: invalid format")
	ErrIncompatibleVersion = errors.New("argon2id: version incompatible")
)

Functions

This section is empty.

Types

type Argon2

type Argon2 interface {
	Hash(password string) (string, error)
	Compare(password, hash string) (match bool, err error)
}

func CreateArgon2

func CreateArgon2(random io.Reader, config Argon2Config) Argon2

Creates a new Argon2id password hasher using default parameters using user-defined parameters.

func NewArgon2

func NewArgon2(random io.Reader) Argon2

Creates a new Argon2id password hasher using default parameters:

Memory: 65536 Iterations: 3 Parallelism: 2 SaltLength: 16 KeyLength: 32

type Argon2Config

type Argon2Config struct {
	Memory      uint32 `yaml:"memory" json:"memory" mapstructure:"memory"`
	Iterations  uint32 `yaml:"iterations" json:"iterations" mapstructure:"iterations"`
	Parallelism uint8  `yaml:"parallelism" json:"parallelism" mapstructure:"parallelism"`
	SaltLength  uint32 `yaml:"saltLen" json:"saltLen" mapstructure:"saltLen"`
	KeyLength   uint32 `yaml:"keyLen" json:"keyLen" mapstructure:"keyLen"`
}

type Argon2Hasher

type Argon2Hasher struct {
	Argon2
	// contains filtered or unexported fields
}

func (Argon2Hasher) Compare

func (hasher Argon2Hasher) Compare(password,
	encodedHash string) (match bool, err error)

func (Argon2Hasher) Hash

func (hasher Argon2Hasher) Hash(password string) (string, error)

Hashes the password using Argon2id

Jump to

Keyboard shortcuts

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