passwd

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package passwd hashes and verifies passwords with Argon2id, producing and consuming standard PHC strings ($argon2id$v=19$m=..,t=..,p=..$salt$hash). The cost parameters travel with each hash, so changing profiles never breaks verification of existing hashes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Standard is the OWASP minimum for Argon2id (19 MiB).
	Standard = Profile{MemoryKiB: 19 * 1024, Time: 2, Threads: 1}
	// High (32 MiB) is Ken's default for the human login.
	High = Profile{MemoryKiB: 32 * 1024, Time: 2, Threads: 1}
)

Functions

func Hash

func Hash(password string, p Profile) (string, error)

Hash hashes password with the given profile and returns a PHC string.

func Verify

func Verify(password, phc string) (bool, error)

Verify reports whether password matches the PHC-encoded hash. It reads the cost parameters from the hash itself, so hashes made with any profile verify.

Types

type Profile

type Profile struct {
	MemoryKiB uint32
	Time      uint32
	Threads   uint8
}

Profile selects Argon2id cost parameters (salt 16, hash 32, t=2, p=1 in both; only the memory cost differs). Standard is the OWASP minimum for Argon2id; Ken defaults to High because a curator account is the only thing standing between an attacker and the whole knowledge base, and logins are rare enough that the extra memory cost is never on a hot path.

Jump to

Keyboard shortcuts

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