Documentation
¶
Overview ¶
Package password abstracts password hashing behind the Hasher interface and ships an Argon2id implementation as the secure default.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMismatch is returned by Hasher.Verify when the password does not match the hash. ErrMismatch = errors.New("password: hash and password do not match") // ErrInvalidHash is returned when an encoded hash cannot be parsed. ErrInvalidHash = errors.New("password: invalid encoded hash") // ErrIncompatibleVersion is returned when the hash was produced by another Argon2 version. ErrIncompatibleVersion = errors.New("password: incompatible argon2 version") )
View Source
var DefaultArgon2idParams = Argon2idParams{
Memory: 19 * 1024,
Iterations: 2,
Parallelism: 1,
SaltLength: 16,
KeyLength: 32,
}
DefaultArgon2idParams follows the OWASP Password Storage recommendation (m=19 MiB, t=2, p=1).
Functions ¶
func SetRandReaderForTesting ¶
SetRandReaderForTesting overrides the entropy source during unit tests and returns a restore func.
Types ¶
type Argon2id ¶
type Argon2id struct {
// contains filtered or unexported fields
}
Argon2id is a Hasher producing PHC formatted strings:
$argon2id$v=19$m=19456,t=2,p=1$<salt>$<key>
Verification reads parameters from the hash itself, so parameters can be raised over time without invalidating existing hashes.
func NewArgon2id ¶
func NewArgon2id(params Argon2idParams) *Argon2id
NewArgon2id returns an Argon2id hasher. Zero-valued fields fall back to DefaultArgon2idParams.
Click to show internal directories.
Click to hide internal directories.