Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PasswordHash ¶
type PasswordHash struct { // The Hash and salt. Hash []byte }
A PasswordHash stores a hashed and salted password.
func NewPasswordHash ¶
func NewPasswordHash(password string, cost int) (*PasswordHash, error)
NewPasswordHash hashes and salts a plaintext password with the specified cost.
See golang.org/x/crypto/bcrypt.DefaultCost, golang.org/x/crypto/bcrypt.MinCost and golang.org/x/crypto/bcrypt.MaxCost for the possible values for cost.
func (*PasswordHash) Compare ¶
func (p *PasswordHash) Compare(password string) error
Compare compares the password hash against a plaintext password.
Returns nil if the password matches, or an error otherwise.
func (*PasswordHash) MarshalJSON ¶
func (p *PasswordHash) MarshalJSON() ([]byte, error)
MarshalJSON encodes the password hash as a quoted string.
func (*PasswordHash) UnmarshalJSON ¶
func (p *PasswordHash) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the password hash from a quoted string.
type User ¶
type User struct { ID uint64 Email string Password *PasswordHash }
Click to show internal directories.
Click to hide internal directories.