2015-09-29 22:35:25 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-10-01 13:38:42 +00:00
|
|
|
"zxcvbn-go/matching"
|
2015-10-06 18:43:37 +00:00
|
|
|
"zxcvbn-go/scoring"
|
|
|
|
"time"
|
|
|
|
"zxcvbn-go/utils/math"
|
2015-09-29 22:35:25 +00:00
|
|
|
)
|
|
|
|
|
2015-10-01 13:38:42 +00:00
|
|
|
func main() {
|
2015-10-06 18:43:37 +00:00
|
|
|
password :="qw@!abcdPLSB$6D"
|
|
|
|
fmt.Println(PasswordStrength(password, nil))
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2015-09-29 22:35:25 +00:00
|
|
|
}
|