hash

package
v0.0.0-...-185ace6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Argon2DefaultMemory      uint32 = 4 * 1024 * 1024
	Argon2DefaultIterations  uint32 = 4
	Argon2DefaultParallelism uint8  = 8
	Argon2DefaultSaltLength  uint32 = 16
	Argon2DefaultKeyLength   uint32 = 32
)

Variables

View Source
var (
	ErrInvalidHash               = errors.New("the encoded hash is not in the correct format")
	ErrIncompatibleVersion       = errors.New("incompatible version of argon2")
	ErrMismatchedHashAndPassword = errors.New("passwords do not match")
)
View Source
var Argon2CPUParallelism = uint8(runtime.NumCPU() * 2)

Functions

This section is empty.

Types

type Argon2

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

func NewHasherArgon2

func NewHasherArgon2(c HasherArgon2Config) *Argon2

func (*Argon2) Compare

func (h *Argon2) Compare(ctx context.Context, password []byte, hash []byte) error

func (*Argon2) Generate

func (h *Argon2) Generate(ctx context.Context, password []byte) ([]byte, error)

type HashProvider

type HashProvider interface {
	Hasher() Hasher
}

type Hasher

type Hasher interface {
	// Compare a password to a hash and return nil if they match or an error otherwise.
	Compare(ctx context.Context, password []byte, hash []byte) error

	// Generate returns a hash derived from the password or an error if the hash method failed.
	Generate(ctx context.Context, password []byte) ([]byte, error)
}

Hasher provides methods for generating and comparing password hashes.

type HasherArgon2Config

type HasherArgon2Config struct {
	Memory      uint32 `json:"memory" required:"true" default:"4194304"`
	Iterations  uint32 `json:"iterations" required:"true" default:"4"`
	Parallelism uint8  `json:"parallelism" required:"true" default:"8"`
	SaltLength  uint32 `json:"salt_length" required:"true" default:"16" split_words:"true"`
	KeyLength   uint32 `json:"key_length" required:"true" default:"32" split_words:"true"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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