password

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package password provides Argon2id password hashing with encoded parameters.

Index

Constants

This section is empty.

Variables

View Source
var DefaultParameters = Parameters{Memory: 19 * 1024, Iterations: 2, Parallelism: 1, KeyLength: 32, SaltLength: 16}

DefaultParameters define package-level implementation state.

View Source
var ErrInvalidHash = errors.New("invalid password hash")

ErrInvalidHash define package-level implementation state.

Functions

func Compare

func Compare(plain, encoded string) bool

Compare performs this package operation.

func Hash

func Hash(plain string) (string, error)

Hash performs this package operation.

Types

type Hasher

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

Hasher hashes and verifies passwords with one immutable parameter set.

func New

func New(parameters Parameters) Hasher

New performs this package operation.

func (Hasher) Hash

func (h Hasher) Hash(plain string) (string, error)

Hash performs this package operation.

func (Hasher) NeedsRehash

func (h Hasher) NeedsRehash(encoded string) bool

NeedsRehash performs this package operation.

type Parameters

type Parameters struct {
	// Memory store data used by this type.
	Memory uint32
	// Iterations store data used by this type.
	Iterations uint32
	// Parallelism store data used by this type.
	Parallelism uint8
	// KeyLength store data used by this type.
	KeyLength uint32
	// SaltLength store data used by this type.
	SaltLength uint32
}

Parameters defines an implementation type used by this package.

Jump to

Keyboard shortcuts

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