Documentation
¶
Overview ¶
Package pwhash generates and compares password hashes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidHash = errors.New("password hash is malformed")
ErrInvalidHash is returned when the password hash is malformed.
View Source
var ErrPasswordMismatch = errors.New("passwords does not match hash")
ErrPasswordMismatch is returned when the password does not match the hash.
Functions ¶
This section is empty.
Types ¶
type Hasher ¶
type Hasher struct { // Secret key used when generating passwords. This is optional, but when // it is used, it's called "peppering". Secret []byte // contains filtered or unexported fields }
Hasher defines parameters for hashing and verifying passwords.
func (Hasher) Verify ¶
Verify returns true if password and encodedHash match.
If the passwords match, this returns nil. Otherwise, it returns an error indicating whether this was caused by password mismatch or by a malformed hash.
It may be helpful to log the reason for error whenever it is not ErrPasswordMismatch, since this may indicate database integrity errors, etc.
Click to show internal directories.
Click to hide internal directories.