passwords

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package passwords provides bcrypt password hashing and strength validation.

Security:

  • bcrypt with cost factor 12 (tunable)
  • Constant-time comparison (built into bcrypt)
  • No plaintext passwords ever stored or logged

Index

Constants

View Source
const (
	// MinPasswordLength is the minimum acceptable password length.
	MinPasswordLength = 8
	// MaxPasswordLength is bcrypt's maximum password byte length.
	MaxPasswordLength = 72
)

Variables

This section is empty.

Functions

func Hash

func Hash(plaintext string) (string, error)

Hash hashes a plaintext password using bcrypt with cost 12. The returned string is suitable for storage (e.g. "$2a$12$...").

func ValidateStrength

func ValidateStrength(password string) []string

ValidateStrength validates password strength and returns a list of issues. An empty slice means the password meets all requirements.

func Verify

func Verify(plaintext, hash string) bool

Verify checks a plaintext password against a bcrypt hash using bcrypt's built-in constant-time comparison to prevent timing attacks. Returns true if the password matches, false otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL