passlib

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package passlib provides password hashing using Argon2id algorithm. Argon2id is the recommended password hashing algorithm by OWASP.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultMemoryCost uint32 = 65536 // 64 MB
	DefaultTimeCost   uint32 = 4
	DefaultThreads    uint8  = 1
)

Default parameters for Argon2id hashing. These values follow OWASP recommendations.

View Source
var (
	ErrInvalidHash         = errors.New("passlib: unable to parse hash value")
	ErrIncompatibleVariant = errors.New("passlib: hash variant is not compatible")
	ErrIncompatibleVersion = errors.New("passlib: hash version is not supported")
	ErrNotMatch            = errors.New("passlib: password does not match hash")
)

Errors returned by passlib functions.

Functions

func Hash

func Hash(password string) (string, error)

Hash generates an Argon2id hash of the password using default parameters. Returns a PHC-formatted string that includes the algorithm, version, parameters, salt, and hash.

func NeedsRehash added in v1.0.0

func NeedsRehash(hash string) bool

NeedsRehash checks if the hash was created with outdated parameters and should be rehashed with current default parameters.

func Verify

func Verify(password string, hash string) error

Verify checks if the password matches the given hash. Returns nil if the password matches, or an error otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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