passwords

package
v0.0.0-...-176c731 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

services/auth/authn/passwords/passwords.go

Index

Constants

This section is empty.

Variables

View Source
var DefaultArgon2idParams = &Argon2idParams{
	Memory:      64 * 1024,
	Iterations:  3,
	Parallelism: 4,
	SaltLength:  16,
	KeyLength:   32,
}

DefaultArgon2idParams provides recommended default parameters. OWASP recommendations suggest t>=2, m>=19MiB (19456 KiB). Adjust these based on performance testing on your hardware.

Functions

func HashPassword

func HashPassword(password string) (string, error)

HashPassword securely hashes a password using Argon2id and returns a PHC string.

func VerifyPassword

func VerifyPassword(password string, encodedHash string) (bool, error)

VerifyPassword compares a plaintext password with a stored Argon2id hash (PHC format).

Types

type Argon2idParams

type Argon2idParams struct {
	Memory      uint32 // Memory cost in KiB
	Iterations  uint32 // Time cost (number of passes)
	Parallelism uint8  // Parallelism factor (threads)
	SaltLength  uint32 // Length of the salt in bytes
	KeyLength   uint32 // Length of the derived key (hash) in bytes
}

Argon2idParams holds the parameters for Argon2id hashing. These parameters can be tuned based on your security requirements and server resources.

Jump to

Keyboard shortcuts

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