Documentation ¶
Overview ¶
Package valpass can be used to validate password quality using different metrics.
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dictionary ¶
type Dictionary struct { Words []string // Contains the actual dictionary. Submatch bool // Set to true to enable submatches, e.g. 'foo' would match 'foobar', default is false. Fuzzy bool // Set to true to enable more lax dictionary checks, default is false. }
Dictionary is a container struct to store and submit a dictionary of words.
type Levenshtein ¶
type Levenshtein struct { // CaseSensitive specifies if the string comparison is case sensitive. CaseSensitive bool // InsertCost represents the Levenshtein cost of a character insertion. InsertCost int // InsertCost represents the Levenshtein cost of a character deletion. DeleteCost int // InsertCost represents the Levenshtein cost of a character substitution. ReplaceCost int }
Levenshtein represents the Levenshtein metric for measuring the similarity between sequences.
For more information see https://en.wikipedia.org/wiki/Levenshtein_distance.
func NewLevenshtein ¶
func NewLevenshtein() *Levenshtein
NewLevenshtein returns a new Levenshtein string metric.
Default options:
CaseSensitive: true InsertCost: 1 DeleteCost: 1 ReplaceCost: 1
func (*Levenshtein) Compare ¶
func (m *Levenshtein) Compare(a, b string) float64
Compare returns the Levenshtein similarity of a and b. The returned similarity is a number between 0 and 1. Larger similarity numbers indicate closer matches.
func (*Levenshtein) Distance ¶
func (m *Levenshtein) Distance(a, b string) int
Distance returns the Levenshtein distance between a and b. Lower distances indicate closer matches. A distance of 0 means the strings are identical.
type Options ¶
type Options struct { Compress int // minimum compression rate in percent, default 10% CharDistribution float64 // minimum character distribution in percent, default 10% Entropy float64 // minimum entropy value in bits/char, default 3 bits/s Dictionary *Dictionary // lookup given dictionary, the caller has to provide it }
Options struct can be used to configure the validator, turn on/off certain validator functions and tune the thresholds when to flag a password as valid.
Set option to zero or false to disable the feature.
type Result ¶
type Result struct { Ok bool // overall result DictionaryMatch bool // true if the password matched a dictionary entry Compress int // actual compression rate in percent CharDistribution float64 // actual character distribution in percent Entropy float64 // actual entropy value in bits/chars }
Result stores the results of all validations.