2015-10-06 22:21:39 +00:00
|
|
|
package zxcvbn
|
2015-09-29 22:35:25 +00:00
|
|
|
|
|
|
|
import (
|
2017-11-02 13:33:00 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/TheMacies/zxcvbn-go/match"
|
2015-10-07 00:14:08 +00:00
|
|
|
"github.com/nbutton23/zxcvbn-go/matching"
|
|
|
|
"github.com/nbutton23/zxcvbn-go/scoring"
|
|
|
|
"github.com/nbutton23/zxcvbn-go/utils/math"
|
2015-09-29 22:35:25 +00:00
|
|
|
)
|
|
|
|
|
2017-11-02 13:33:00 +00:00
|
|
|
func PasswordStrength(password string, userInputs []string, filters ...func(match.Matcher) bool) scoring.MinEntropyMatch {
|
2015-10-06 18:43:37 +00:00
|
|
|
start := time.Now()
|
2017-11-02 13:33:00 +00:00
|
|
|
matches := matching.Omnimatch(password, userInputs, filters...)
|
2015-10-06 18:43:37 +00:00
|
|
|
result := scoring.MinimumEntropyMatchSequence(password, matches)
|
|
|
|
end := time.Now()
|
|
|
|
|
|
|
|
calcTime := end.Nanosecond() - start.Nanosecond()
|
|
|
|
result.CalcTime = zxcvbn_math.Round(float64(calcTime)*time.Nanosecond.Seconds(), .5, 3)
|
|
|
|
return result
|
2016-01-13 22:49:04 +00:00
|
|
|
}
|