argon2id

package
v0.0.0-...-4b578d8 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package argon2id provides a simple interface for hashing and verifying passwords using the Argon2id algorithm. It offers a default configuration that can be customized as needed.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash         = errors.New("argon2id: invalid hash format")
	ErrIncompatibleVersion = errors.New("argon2id: incompatible version of argon2")
)

Predefined errors.

Functions

This section is empty.

Types

type Config

type Config struct {
	Memory      uint32 // memory cost in kibibytes
	Iterations  uint32 // number of iterations
	Parallelism uint8  // degree of parallelism (number of threads)
	SaltLength  uint32 // length of the random salt in bytes
	KeyLength   uint32 // length of the generated key in bytes
}

Config holds the parameters for the Argon2id algorithm. Users can use DefaultConfig() for recommended defaults. !Important note: Changing the value of the Parallelism parameter changes the hash output.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with recommended settings.

func (*Config) ComparePasswordAndHash

func (c *Config) ComparePasswordAndHash(password, encodedHash string) (bool, error)

ComparePasswordAndHash verifies whether the provided password matches the encoded hash. It returns true if they match.

func (*Config) HashPassword

func (c *Config) HashPassword(password string) (string, error)

HashPassword generates a salted hash for the given password using the Argon2id algorithm and returns the encoded hash string.

Jump to

Keyboard shortcuts

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