mirror of
https://github.com/securego/gosec.git
synced 2024-12-26 12:35:52 +00:00
20 lines
569 B
Go
20 lines
569 B
Go
|
package zxcvbn
|
||
|
|
||
|
import (
|
||
|
"github.com/nbutton23/zxcvbn-go/matching"
|
||
|
"github.com/nbutton23/zxcvbn-go/scoring"
|
||
|
"github.com/nbutton23/zxcvbn-go/utils/math"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func PasswordStrength(password string, userInputs []string) scoring.MinEntropyMatch {
|
||
|
start := time.Now()
|
||
|
matches := matching.Omnimatch(password, userInputs)
|
||
|
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
|
||
|
}
|