Help us shape the future of Go! Take the 2026 Go Developer Survey

password

package
v1.16.18 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// VeryWeak password
	VeryWeak = 0
	// Weak password
	Weak = 1
	// Fair password
	Fair = 2
	// Strong password
	Strong = 3
	// VeryStrong password
	VeryStrong = 4

	// OK password is the recommended minimum strength for API calls
	OK = Fair
)

Variables

View Source
var (
	ErrEmptyPassword = errors.New("empty password")
	ErrPassMaxLength = fmt.Errorf("password exceeds maximum length of %d chars", maxPassLen)
	ErrWeakPassword  = errors.New("password is too weak")
)

Functions

func IsValid

func IsValid(password string, minimumStrength Strength) error

IsValid returns nil if password is a reasonable length and has strength greater than or equal to [minimumStrength]

func SufficientlyStrong

func SufficientlyStrong(password string, minimumStrength Strength) bool

SufficientlyStrong returns true if password has strength greater than or equal to [minimumStrength]

Types

type Hash

type Hash struct {
	Password [32]byte `serialize:"true"` // The salted, hashed password
	Salt     [16]byte `serialize:"true"` // The salt
}

Hash of a password

func (*Hash) Check

func (h *Hash) Check(password string) bool

Check returns true iff the provided password was the same as the last password set.

func (*Hash) Set

func (h *Hash) Set(password string) error

Set updates the password hash to be of the provided password

type Strength

type Strength int

Strength is the strength of a password

Jump to

Keyboard shortcuts

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