phash

package
v0.0.0-...-c2fed7e Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAlgo = errors.New("invalid algorithm was used to verify this password")
View Source
var ErrMalformedHash = errors.New("encoded password hash is malformed and can't be decoded")
View Source
var ErrPasswordInvalid = errors.New("password does not match hash given")

Functions

This section is empty.

Types

type Argon2IDPasswordHasher

type Argon2IDPasswordHasher struct {
	AlgoID  []byte
	SaltRNG io.Reader
	Options Argon2Options // needs to be set, defaults are not valid options
}

func (*Argon2IDPasswordHasher) HashPassword

func (h *Argon2IDPasswordHasher) HashPassword(password []byte) (hash PasswordHash, err error)

func (*Argon2IDPasswordHasher) ValidatePassword

func (h *Argon2IDPasswordHasher) ValidatePassword(password []byte, hash PasswordHash) (err error)

type Argon2Options

type Argon2Options struct {
	Time    uint32
	Memory  uint32
	Threads uint8
	KeyLen  uint32

	SaltLen uint32 // if zero then salt is omited
}

type PasswordHash

type PasswordHash struct {
	RawHash []byte
	Salt    []byte
	AlgoID  []byte
}

func (*PasswordHash) Decode

func (h *PasswordHash) Decode(buf []byte) (err error)

Decode decodes encoded PasswordHash into structure, which has this method called on. Removes any previous data.

func (*PasswordHash) Encode

func (h *PasswordHash) Encode(buf []byte) ([]byte, error)

type PasswordHasher

type PasswordHasher interface {
	HashPassword(password []byte) (hash PasswordHash, err error)
}

type PasswordVerifier

type PasswordVerifier interface {
	ValidatePassword(password []byte, hash PasswordHash) (err error)
}

Jump to

Keyboard shortcuts

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