zxcvbn-go/zxcvbn.go

25 lines
673 B
Go
Raw Normal View History

2015-10-06 22:21:39 +00:00
package zxcvbn
import (
"github.com/nbutton23/zxcvbn-go/matching"
"github.com/nbutton23/zxcvbn-go/scoring"
"github.com/nbutton23/zxcvbn-go/utils/math"
2016-01-13 22:49:04 +00:00
"time"
)
2015-10-06 22:19:04 +00:00
//func main() {
// password :="Testaaatyhg890l33t"
// 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
2016-01-13 22:49:04 +00:00
}