argon2

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package argon2 implements the functions, types, and interfaces for the module.

Index

Constants

View Source
const (
	// DefaultTimeCost is the default time cost for Argon2.
	DefaultTimeCost = 3
	// DefaultMemoryCost is the default memory cost for Argon2.
	DefaultMemoryCost = 64 * 1024 // 64MB
	// DefaultThreads is the default number of threads for Argon2.
	DefaultThreads = 4
	// DefaultKeyLength is the default key length for Argon2.
	DefaultKeyLength = 32
)

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() *types.Config

DefaultConfig returns the default configuration for Argon2

func NewArgon2 added in v0.3.18

func NewArgon2(algSpec types.Spec, config *types.Config) (scheme.Scheme, error)

NewArgon2 creates a new Argon2 crypto instance

func NewArgon2i added in v0.3.18

func NewArgon2i(cfg *types.Config) (scheme.Scheme, error)

func NewArgon2id added in v0.3.18

func NewArgon2id(cfg *types.Config) (scheme.Scheme, error)

func NewDefaultArgon2 added in v0.3.18

func NewDefaultArgon2(config *types.Config) (scheme.Scheme, error)

func ResolveSpec added in v1.1.0

func ResolveSpec(p types.Spec) (types.Spec, error)

func WithKeyLength added in v1.2.0

func WithKeyLength(keyLength uint32) func(*types.Config)

func WithMemoryCost added in v1.2.0

func WithMemoryCost(memoryCost uint32) func(*types.Config)

func WithParams added in v1.2.0

func WithParams(params *Params) func(*types.Config)

func WithThreads added in v1.2.0

func WithThreads(threads uint8) func(*types.Config)

func WithTimeCost added in v1.2.0

func WithTimeCost(timeCost uint32) func(*types.Config)

Types

type Argon2

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

Argon2 implements the Argon2 hashing algorithm

func (*Argon2) Hash

func (c *Argon2) Hash(password string) (*types.HashParts, error)

Hash implements the hash method

func (*Argon2) HashWithSalt

func (c *Argon2) HashWithSalt(password string, salt []byte) (*types.HashParts, error)

HashWithSalt implements the hash with salt method

func (*Argon2) Spec added in v1.1.0

func (c *Argon2) Spec() types.Spec

func (*Argon2) Verify

func (c *Argon2) Verify(parts *types.HashParts, password string) error

Verify implements the verify method

type KeyFunc added in v0.3.18

type KeyFunc func(password []byte, salt []byte, time uint32, memory uint32, threads uint8, keyLen uint32) []byte

func ParseKeyFunc added in v0.3.18

func ParseKeyFunc(algSpec types.Spec) KeyFunc

type Params

type Params struct {
	TimeCost   uint32
	MemoryCost uint32
	Threads    uint8
	KeyLength  uint32
}

Params represents parameters for Argon2 algorithm

func DefaultParams

func DefaultParams() *Params

func FromMap added in v0.3.18

func FromMap(m map[string]string) (params *Params, err error)

FromMap parses Argon2 parameters from string

func (*Params) FromMap added in v0.3.18

func (p *Params) FromMap(params map[string]string) error

func (*Params) IsNil added in v1.1.0

func (p *Params) IsNil() bool

func (*Params) String

func (p *Params) String() string

String returns the string representation of parameters

func (*Params) ToMap added in v0.3.18

func (p *Params) ToMap() map[string]string

ToMap converts Params to a map[string]string

func (*Params) Validate added in v0.3.18

func (p *Params) Validate(config *types.Config) error

Jump to

Keyboard shortcuts

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