Documentation
¶
Overview ¶
Package password provides secure password hashing and validation.
Index ¶
Constants ¶
const DefaultCost = 12
DefaultCost is the default bcrypt cost factor. This provides a good balance between security and performance.
Variables ¶
var ( ErrPasswordTooShort = errors.New("password is too short") ErrPasswordNoUppercase = errors.New("password must contain at least one uppercase letter") ErrPasswordNoLowercase = errors.New("password must contain at least one lowercase letter") ErrPasswordNoNumber = errors.New("password must contain at least one number") ErrPasswordNoSpecial = errors.New("password must contain at least one special character") ErrPasswordMismatch = errors.New("password does not match") ErrInvalidHash = errors.New("invalid password hash") )
Errors for password operations.
Functions ¶
func GenerateResetToken ¶
GenerateResetToken generates a password reset token. Returns a 32-byte (256-bit) secure random token.
func GenerateSecureToken ¶
GenerateSecureToken generates a cryptographically secure random token. The token is URL-safe base64 encoded.
func GenerateVerificationToken ¶
GenerateVerificationToken generates an email verification token. Returns a 32-byte (256-bit) secure random token.
func ValidateWithPolicy ¶
ValidateWithPolicy validates a password against a specific policy.
Types ¶
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher provides password hashing and verification operations.
func (*Hasher) NeedsRehash ¶
NeedsRehash checks if a hash needs to be updated due to cost changes.