lib_meter.go

 1package passwordstrength
 2
 3import passwordvalidator "github.com/wagslane/go-password-validator"
 4
 5type LibMeter struct{}
 6
 7func NewLibMeter() LibMeter {
 8	return LibMeter{}
 9}
10
11func (m LibMeter) Strength(password string) Strength {
12	entropy := passwordvalidator.GetEntropy(password)
13	switch {
14	case entropy >= strongEntropyBits:
15		return Strong
16	case entropy >= mediumEntropyBits:
17		return Medium
18	default:
19		return Weak
20	}
21}