crunchy: github.com/muesli/crunchy Index | Files

package crunchy

import "github.com/muesli/crunchy"

Index

Package Files

crunchy.go errors.go hibp.go hibp_go1.6.go stringutils.go

Variables

var (
    // ErrEmpty gets returned when the password is empty or all whitespace
    ErrEmpty = errors.New("Password is empty or all whitespace")
    // ErrTooShort gets returned when the password is not long enough
    ErrTooShort = errors.New("Password is too short")
    // ErrTooFewChars gets returned when the password does not contain enough unique characters
    ErrTooFewChars = errors.New("Password does not contain enough different/unique characters")
    // ErrNoDigits gets returned when the password does not contain any digits
    ErrNoDigits = errors.New("Password does not contain any digits")
    // ErrNoSymbols gets returned when the password does not contain any symbols
    ErrNoSymbols = errors.New("Password does not contain any special symbols")
    // ErrTooSystematic gets returned when the password is too systematic (e.g. 123456, abcdef)
    ErrTooSystematic = errors.New("Password is too systematic")
    // ErrDictionary gets returned when the password is found in a dictionary
    ErrDictionary = errors.New("Password is too common / from a dictionary")
    // ErrMangledDictionary gets returned when the password is mangled, but found in a dictionary
    ErrMangledDictionary = errors.New("Password is mangled, but too common / from a dictionary")
    // ErrHashedDictionary gets returned when the password is hashed, but found in a dictionary
    ErrHashedDictionary = errors.New("Password is hashed, but too common / from a dictionary")
    // ErrFoundHIBP gets returned when the password has been found on https://haveibeenpwned.com
    ErrFoundHIBP = errors.New("Password has been found inside haveibeenpwned.com database")
)
var HttpClient = &http.Client{
    Transport: &http.Transport{
        Dial: (&net.Dialer{
            Timeout: 30 * time.Second,
        }).Dial,
        ResponseHeaderTimeout: 10 * time.Second,
    },
}

type DictionaryError Uses

type DictionaryError struct {
    Err      error
    Word     string
    Distance int
}

DictionaryError wraps an ErrMangledDictionary with contextual information

func (*DictionaryError) Error Uses

func (e *DictionaryError) Error() string

type HashedDictionaryError Uses

type HashedDictionaryError struct {
    Err  error
    Word string
}

HashedDictionaryError wraps an ErrHashedDictionary with contextual information

func (*HashedDictionaryError) Error Uses

func (e *HashedDictionaryError) Error() string

type Options Uses

type Options struct {
    // MinLength is the minimum length required for a valid password (>=1, default is 8)
    MinLength int
    // MinDiff is the minimum amount of unique characters required for a valid password (>=1, default is 5)
    MinDiff int
    // MinDist is the minimum WagnerFischer distance for mangled password dictionary lookups (>=0, default is 3)
    MinDist int
    // Hashers will be used to find hashed passwords in dictionaries
    Hashers []hash.Hash
    // DictionaryPath contains all the dictionaries that will be parsed (default is /usr/share/dict)
    DictionaryPath string
    // Check haveibeenpwned.com database
    CheckHIBP bool
    // MustContainDigit requires at least one digit for a valid password
    MustContainDigit bool
    // MustContainSymbol requires at least one special symbol for a valid password
    MustContainSymbol bool
}

Options contains all the settings for a Validator

type Validator Uses

type Validator struct {
    // contains filtered or unexported fields
}

Validator is used to setup a new password validator with options and dictionaries

func NewValidator Uses

func NewValidator() *Validator

NewValidator returns a new password validator with default settings

func NewValidatorWithOpts Uses

func NewValidatorWithOpts(options Options) *Validator

NewValidatorWithOpts returns a new password validator with custom settings

func (*Validator) Check Uses

func (v *Validator) Check(password string) error

Check validates a password for common flaws It returns nil if the password is considered acceptable.

func (*Validator) Rate Uses

func (v *Validator) Rate(password string) (uint, error)

Rate grades a password's strength from 0 (weak) to 100 (strong).

Package crunchy imports 17 packages (graph) and is imported by 11 packages. Updated 2020-10-28. Refresh now. Tools for package owners.