argon2

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package argon2 contains the Argon2id hasher implementation.

Index

Constants

View Source
const (
	MinMemory      = 32 * 1024
	MinIterations  = 2
	MinParallelism = 1
	MaxMemory      = 1024 * 1024
	MaxIterations  = 100
	MaxParallelism = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Argon2idHasher

type Argon2idHasher struct {
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
	SaltLength  uint32
	KeyLength   uint32
}

Argon2idHasher wraps parameterized Argon2id hashing operations.

func Default

func Default() *Argon2idHasher

Default returns an Argon2idHasher configured with library defaults.

func (*Argon2idHasher) Hash

func (a *Argon2idHasher) Hash(password []byte) (string, error)

Hash derives an Argon2id key, zeroizes inputs, and returns the PHC string.

func (*Argon2idHasher) ID

func (a *Argon2idHasher) ID() string

ID reports the PHC algorithm identifier.

func (*Argon2idHasher) NeedsRehash

func (a *Argon2idHasher) NeedsRehash(encoded string) (bool, error)

NeedsRehash reports whether the encoded parameters diverge from the current configuration.

func (*Argon2idHasher) Verify

func (a *Argon2idHasher) Verify(password []byte, encoded string) (bool, error)

Verify recomputes the Argon2id hash, zeroizes temporaries, and compares it in constant time.

type PolicyParams added in v0.2.0

type PolicyParams struct {
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
}

PolicyParams captures the Argon2 tuning knobs for a policy preset.

func ParamsForPolicy added in v0.2.0

func ParamsForPolicy(p int) (PolicyParams, error)

ParamsForPolicy returns the Argon2 parameters associated with the policy id.

Jump to

Keyboard shortcuts

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