Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashPassword ¶
HashPassword hashes against the current preferred hasher.
func VerifyPassword ¶
VerifyPassword verifies an entered password against a hashed password and returns whether the hash is "stale" (i.e., was verified using the FIRST preferred hasher above).
Types ¶
type BcryptPasswordHasher ¶
type BcryptPasswordHasher struct {
Cost int
}
BcryptPasswordHasher handles password hashing with Bcrypt. Create with `0` as the work factor to default to bcrypt.DefaultCost at hashing time. The Cost field represents work factor.
func (BcryptPasswordHasher) HashPassword ¶
func (h BcryptPasswordHasher) HashPassword(password string) (string, error)
HashPassword creates a one-way digest ("hash") of a password. In the case of Bcrypt, a pseudorandom salt is included automatically by the underlying library. For security reasons, the work factor is always at _least_ bcrypt.DefaultCost.
func (BcryptPasswordHasher) VerifyPassword ¶
func (h BcryptPasswordHasher) VerifyPassword(password, hashedPassword string) bool
VerifyPassword validates whether a one-way digest ("hash") of a password was created from a given plaintext password.
type DummyPasswordHasher ¶
type DummyPasswordHasher struct{}
DummyPasswordHasher is for testing ONLY. DO NOT USE in a production context.
func (DummyPasswordHasher) HashPassword ¶
func (h DummyPasswordHasher) HashPassword(password string) (string, error)
HashPassword creates a one-way digest ("hash") of a password. In the case of Bcrypt, a pseudorandom salt is included automatically by the underlying library.
func (DummyPasswordHasher) VerifyPassword ¶
func (h DummyPasswordHasher) VerifyPassword(password, hashedPassword string) bool
VerifyPassword validates whether a one-way digest ("hash") of a password was created from a given plaintext password.